@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.js CHANGED
@@ -305,81 +305,6 @@ var constants = {
305
305
  }
306
306
  };
307
307
 
308
- // src/mappers/personal-business-details-mapper.js
309
- var mapPersonalBusinessDetails = (value) => {
310
- return {
311
- userName: mappers.customerName(value.customer.info.name),
312
- business: {
313
- organisationId: value.business.organisationId ?? null,
314
- sbi: value.business.sbi ?? null,
315
- name: value.business.info.name ?? null
316
- }
317
- };
318
- };
319
-
320
- // src/mappers/address-mapper.js
321
- var mapAddress = (address = {}) => {
322
- return {
323
- lookup: {
324
- pafOrganisationName: address.pafOrganisationName,
325
- buildingNumberRange: address.buildingNumberRange,
326
- flatName: address.flatName,
327
- buildingName: address.buildingName,
328
- dependentLocality: address.dependentLocality,
329
- doubleDependentLocality: address.doubleDependentLocality,
330
- street: address.street,
331
- county: address.county,
332
- uprn: address.uprn
333
- },
334
- manual: {
335
- line1: address.line1,
336
- line2: address.line2,
337
- line3: address.line3,
338
- line4: address.line4,
339
- line5: address.line5
340
- },
341
- city: address.city,
342
- postcode: address.postalCode,
343
- country: address.country
344
- };
345
- };
346
-
347
- // src/mappers/customer-name-mapper.js
348
- var mapCustomerName = (name = {}) => {
349
- return [
350
- name.first,
351
- name.last
352
- ].filter(Boolean).join(" ");
353
- };
354
-
355
- // src/mappers/business-details-mapper.js
356
- var asNullable = (value) => value ?? null;
357
- var mapBusinessDetails = (value) => {
358
- var _a, _b, _c, _d, _e, _f;
359
- const business = (value == null ? void 0 : value.business) ?? {};
360
- const info = business.info ?? {};
361
- const registrationNumbers = info.registrationNumbers ?? {};
362
- return {
363
- sbi: business.sbi,
364
- businessName: asNullable(info.name),
365
- vat: asNullable(info.vat),
366
- traderNumber: asNullable(info.traderNumber),
367
- vendorNumber: asNullable(info.vendorNumber),
368
- legalStatus: asNullable((_a = info.legalStatus) == null ? void 0 : _a.type),
369
- legalStatusCode: asNullable((_b = info.legalStatus) == null ? void 0 : _b.code),
370
- registrationNumbers: {
371
- companiesHouse: asNullable(registrationNumbers.companiesHouse),
372
- charityCommission: asNullable(registrationNumbers.charityCommission)
373
- },
374
- type: asNullable((_c = info.type) == null ? void 0 : _c.type),
375
- countyParishHoldingNumbers: business.countyParishHoldings ?? [],
376
- address: mapAddress(info.address),
377
- email: asNullable((_d = info.email) == null ? void 0 : _d.address),
378
- landline: asNullable((_e = info.phone) == null ? void 0 : _e.landline),
379
- mobile: asNullable((_f = info.phone) == null ? void 0 : _f.mobile)
380
- };
381
- };
382
-
383
308
  // src/utils/joi.js
384
309
  import BaseJoi from "joi";
385
310
  var Joi = BaseJoi.extend((joi) => ({
@@ -884,127 +809,219 @@ var filterAndJoin = (addressesProperties) => {
884
809
  return addressesProperties.filter(Boolean).join(", ") || null;
885
810
  };
886
811
 
887
- // src/mappers/mappers.js
888
- var mappers = {
889
- personalBusinessDetails: mapPersonalBusinessDetails,
890
- address: mapAddress,
891
- customerName: mapCustomerName,
892
- businessDetails: mapBusinessDetails,
893
- addressLookup: addressLookupMapper
812
+ // src/mappers/address-mapper.js
813
+ var mapAddress = (address = {}) => {
814
+ return {
815
+ lookup: {
816
+ pafOrganisationName: address.pafOrganisationName,
817
+ buildingNumberRange: address.buildingNumberRange,
818
+ flatName: address.flatName,
819
+ buildingName: address.buildingName,
820
+ dependentLocality: address.dependentLocality,
821
+ doubleDependentLocality: address.doubleDependentLocality,
822
+ street: address.street,
823
+ county: address.county,
824
+ uprn: address.uprn
825
+ },
826
+ manual: {
827
+ line1: address.line1,
828
+ line2: address.line2,
829
+ line3: address.line3,
830
+ line4: address.line4,
831
+ line5: address.line5
832
+ },
833
+ city: address.city,
834
+ postcode: address.postalCode,
835
+ country: address.country
836
+ };
894
837
  };
895
838
 
896
- // src/mutations/business/update-business-email.js
897
- var updateBusinessEmailMutation = `
898
- mutation UpdateBusinessEmail($input: UpdateBusinessEmailInput!) {
899
- updateBusinessEmail(input: $input) {
900
- business {
901
- info {
902
- email {
903
- address
904
- }
905
- }
906
- }
907
- success
908
- }
909
- }
910
- `;
839
+ // src/mappers/business-details-mapper.js
840
+ var asNullable = (value) => {
841
+ return value ?? null;
842
+ };
843
+ var mapBusinessDetails = (value) => {
844
+ var _a, _b, _c, _d, _e, _f;
845
+ const business = (value == null ? void 0 : value.business) ?? {};
846
+ const info = business.info ?? {};
847
+ const registrationNumbers = info.registrationNumbers ?? {};
848
+ return {
849
+ sbi: business.sbi,
850
+ businessName: asNullable(info.name),
851
+ vat: asNullable(info.vat),
852
+ traderNumber: asNullable(info.traderNumber),
853
+ vendorNumber: asNullable(info.vendorNumber),
854
+ legalStatus: asNullable((_a = info.legalStatus) == null ? void 0 : _a.type),
855
+ legalStatusCode: asNullable((_b = info.legalStatus) == null ? void 0 : _b.code),
856
+ registrationNumbers: {
857
+ companiesHouse: asNullable(registrationNumbers.companiesHouse),
858
+ charityCommission: asNullable(registrationNumbers.charityCommission)
859
+ },
860
+ type: asNullable((_c = info.type) == null ? void 0 : _c.type),
861
+ countyParishHoldingNumbers: business.countyParishHoldings ?? [],
862
+ address: mapAddress(info.address),
863
+ email: asNullable((_d = info.email) == null ? void 0 : _d.address),
864
+ landline: asNullable((_e = info.phone) == null ? void 0 : _e.landline),
865
+ mobile: asNullable((_f = info.phone) == null ? void 0 : _f.mobile)
866
+ };
867
+ };
911
868
 
912
- // src/mutations/business/update-business-name.js
913
- var updateBusinessNameMutation = `
914
- mutation UpdateBusinessName($input: UpdateBusinessNameInput!) {
915
- updateBusinessName(input: $input) {
916
- business {
917
- info {
918
- name
919
- }
920
- }
921
- success
922
- }
923
- }
924
- `;
869
+ // src/mappers/customer-name-mapper.js
870
+ var mapCustomerName = (name = {}) => {
871
+ return [
872
+ name.first,
873
+ name.last
874
+ ].filter(Boolean).join(" ");
875
+ };
925
876
 
926
- // src/mutations/business/update-business-phone-numbers.js
927
- var updateBusinessPhoneNumbersMutation = `
928
- mutation UpdateBusinessPhoneNumbers($input: UpdateBusinessPhoneInput!) {
929
- updateBusinessPhone(input: $input) {
930
- business {
931
- info {
932
- phone {
933
- landline
934
- mobile
935
- }
936
- }
937
- }
877
+ // src/mappers/personal-business-details-mapper.js
878
+ var mapPersonalBusinessDetails = (value) => {
879
+ return {
880
+ userName: mappers.customerName(value.customer.info.name),
881
+ business: {
882
+ organisationId: value.business.organisationId ?? null,
883
+ sbi: value.business.sbi ?? null,
884
+ name: value.business.info.name ?? null
938
885
  }
939
- }
940
- `;
886
+ };
887
+ };
941
888
 
942
- // src/mutations/personal/update-customer-name.js
943
- var updateCustomerNameMutation = `
944
- mutation UpdateCustomerName($input: UpdateCustomerNameInput!) {
945
- updateCustomerName(input: $input) {
946
- customer {
947
- info {
948
- name {
949
- first
950
- last
951
- middle
952
- }
953
- }
954
- }
955
- }
956
- }
957
- `;
889
+ // src/utils/format-full-name.js
890
+ var formatFullName = (nameData) => {
891
+ return [
892
+ nameData.first,
893
+ nameData.middle,
894
+ nameData.last
895
+ ].filter(Boolean).join(" ");
896
+ };
958
897
 
959
- // src/mutations/personal/update-customer-dob.js
960
- var updateCustomerDobMutation = `
961
- mutation UpdateCustomerDateOfBirth($input: UpdateCustomerDateOfBirthInput!) {
962
- updateCustomerDateOfBirth(input: $input) {
963
- customer {
964
- info {
965
- dateOfBirth
898
+ // src/utils/format-validation-errors.js
899
+ var formatValidationErrors = (errors) => {
900
+ const formattedErrors = {};
901
+ errors.forEach((error) => {
902
+ const { type, context, message: text, path } = error;
903
+ if (Array.isArray(path) && path.length > 1) {
904
+ for (const field of path) {
905
+ if (!formattedErrors[field]) {
906
+ formattedErrors[field] = { text };
966
907
  }
967
908
  }
909
+ return;
968
910
  }
969
- }
970
- `;
971
-
972
- // src/mutations/personal/update-customer-phone.js
973
- var updateCustomerPhoneMutation = `
974
- mutation UpdateCustomerPhone($input: UpdateCustomerPhoneInput!) {
975
- updateCustomerPhone(input: $input) {
976
- customer {
977
- info {
978
- phone {
979
- landline
980
- mobile
981
- }
982
- }
983
- }
911
+ if (type === "object.missing" && Array.isArray(context == null ? void 0 : context.peers)) {
912
+ context.peers.forEach((peer) => {
913
+ formattedErrors[peer] = { text };
914
+ });
915
+ return;
984
916
  }
985
- }
986
- `;
987
-
988
- // src/mutations/personal/update-customer-email.js
989
- var updateCustomerEmailMutation = `
990
- mutation UpdateCustomerEmail($input: UpdateCustomerEmailInput!) {
991
- updateCustomerEmail(input: $input) {
992
- customer {
993
- info {
994
- email {
995
- address
996
- }
997
- }
998
- }
917
+ if (!formattedErrors[path[0]]) {
918
+ formattedErrors[path[0]] = { text };
919
+ }
920
+ });
921
+ return formattedErrors;
922
+ };
923
+
924
+ // src/utils/build-update-business-email-variables.js
925
+ var buildUpdateBusinessEmailVariables = (email, sbi) => {
926
+ return { input: { email: { address: email }, sbi } };
927
+ };
928
+
929
+ // src/utils/build-update-business-name-variables.js
930
+ var buildUpdateBusinessNameVariables = (name, sbi) => {
931
+ return { input: { name, sbi } };
932
+ };
933
+
934
+ // src/utils/build-update-business-phone-numbers-variables.js
935
+ var buildUpdateBusinessPhoneNumbersVariables = (businessTelephone, businessMobile, sbi) => {
936
+ return {
937
+ input: {
938
+ phone: {
939
+ landline: businessTelephone ?? null,
940
+ mobile: businessMobile ?? null
941
+ },
942
+ sbi
943
+ }
944
+ };
945
+ };
946
+
947
+ // src/utils/build-update-business-vat-variables.js
948
+ var buildUpdateBusinessVatVariables = (vat, sbi) => {
949
+ return {
950
+ input: {
951
+ vat,
952
+ sbi
999
953
  }
954
+ };
955
+ };
956
+
957
+ // src/utils/utils.js
958
+ var utils = {
959
+ formatFullName,
960
+ formatValidationErrors,
961
+ buildUpdateBusinessEmailVariables,
962
+ buildUpdateBusinessNameVariables,
963
+ buildUpdateBusinessPhoneNumbersVariables,
964
+ buildUpdateBusinessVatVariables
965
+ };
966
+
967
+ // src/mappers/personal-details-mapper.js
968
+ var asNullable2 = (value) => {
969
+ return value ?? null;
970
+ };
971
+ var mapPersonalDetails = (value) => {
972
+ var _a, _b, _c;
973
+ protectAgainstNull(value);
974
+ const customerInfo = value.customer.info;
975
+ const customerName = customerInfo.name;
976
+ const [year, month, day] = customerInfo.dateOfBirth ? customerInfo.dateOfBirth.split("-") : [];
977
+ return {
978
+ crn: value.customer.crn ?? null,
979
+ userName: customerName ? mapCustomerName(customerName) : null,
980
+ fullName: {
981
+ first: asNullable2(customerName == null ? void 0 : customerName.first),
982
+ last: asNullable2(customerName == null ? void 0 : customerName.last),
983
+ middle: asNullable2(customerName == null ? void 0 : customerName.middle)
984
+ },
985
+ fullNameJoined: customerName ? utils.formatFullName(customerName) : "",
986
+ dateOfBirth: {
987
+ full: asNullable2(customerInfo.dateOfBirth),
988
+ day: asNullable2(day),
989
+ month: asNullable2(month),
990
+ year: asNullable2(year)
991
+ },
992
+ address: customerInfo.address ? mapAddress(customerInfo.address) : {},
993
+ email: asNullable2((_a = customerInfo.email) == null ? void 0 : _a.address),
994
+ telephone: asNullable2((_b = customerInfo.phone) == null ? void 0 : _b.landline),
995
+ mobile: asNullable2((_c = customerInfo.phone) == null ? void 0 : _c.mobile)
996
+ };
997
+ };
998
+ var protectAgainstNull = (value) => {
999
+ if (value === null || value === void 0) {
1000
+ throw new Error("Personal details value cannot be null or undefined");
1000
1001
  }
1001
- `;
1002
+ if (!value.customer) {
1003
+ throw new Error("Personal details value must contain a customer object");
1004
+ }
1005
+ if (!value.customer.info) {
1006
+ throw new Error("Customer must contain an info object");
1007
+ }
1008
+ };
1002
1009
 
1003
- // src/mutations/personal/update-customer-address.js
1004
- var updateCustomerAddressMutation = `
1005
- mutation UpdateCustomerAddress($input: UpdateCustomerAddressInput!) {
1006
- updateCustomerAddress(input: $input) {
1007
- customer {
1010
+ // src/mappers/mappers.js
1011
+ var mappers = {
1012
+ address: mapAddress,
1013
+ addressLookup: addressLookupMapper,
1014
+ businessDetails: mapBusinessDetails,
1015
+ customerName: mapCustomerName,
1016
+ personalBusinessDetails: mapPersonalBusinessDetails,
1017
+ personalDetails: mapPersonalDetails
1018
+ };
1019
+
1020
+ // src/mutations/business/update-business-address.js
1021
+ var updateBusinessAddressMutation = `
1022
+ mutation UpdateBusinessAddress($input: UpdateBusinessAddressInput!) {
1023
+ updateBusinessAddress(input: $input) {
1024
+ business {
1008
1025
  info {
1009
1026
  address {
1010
1027
  line1
@@ -1028,30 +1045,91 @@ var updateCustomerAddressMutation = `
1028
1045
  }
1029
1046
  `;
1030
1047
 
1031
- // src/mutations/business/update-business-address.js
1032
- var updateBusinessAddressMutation = `
1033
- mutation UpdateBusinessAddress($input: UpdateBusinessAddressInput!) {
1034
- updateBusinessAddress(input: $input) {
1048
+ // src/mutations/business/update-business-details.js
1049
+ var updateBusinessDetailsMutation = `
1050
+ mutation UpdateBusinessAllFields($input: UpdateBusinessAllFieldsInput!) {
1051
+ updateBusinessAllFields(input: $input) {
1052
+ success
1053
+ }
1054
+ }
1055
+ `;
1056
+
1057
+ // src/mutations/business/update-business-email.js
1058
+ var updateBusinessEmailMutation = `
1059
+ mutation UpdateBusinessEmail($input: UpdateBusinessEmailInput!) {
1060
+ updateBusinessEmail(input: $input) {
1035
1061
  business {
1036
1062
  info {
1037
- address {
1038
- line1
1039
- line2
1040
- line3
1041
- line4
1042
- line5
1043
- postalCode
1044
- country
1045
- city
1046
- buildingNumberRange
1047
- buildingName
1048
- flatName
1049
- street
1050
- county
1051
- uprn
1063
+ email {
1064
+ address
1065
+ }
1066
+ }
1067
+ }
1068
+ success
1069
+ }
1070
+ }
1071
+ `;
1072
+
1073
+ // src/mutations/business/update-business-legal-status.js
1074
+ var updateBusinessLegalStatusMutation = `
1075
+ mutation UpdateBusinessLegalStatus($input: UpdateBusinessLegalStatusInput!) {
1076
+ updateBusinessLegalStatus(input: $input) {
1077
+ business {
1078
+ info {
1079
+ legalStatus {
1080
+ code
1081
+ type
1082
+ }
1083
+ }
1084
+ }
1085
+ success
1086
+ }
1087
+ }
1088
+ `;
1089
+
1090
+ // src/mutations/business/update-business-name.js
1091
+ var updateBusinessNameMutation = `
1092
+ mutation UpdateBusinessName($input: UpdateBusinessNameInput!) {
1093
+ updateBusinessName(input: $input) {
1094
+ business {
1095
+ info {
1096
+ name
1097
+ }
1098
+ }
1099
+ success
1100
+ }
1101
+ }
1102
+ `;
1103
+
1104
+ // src/mutations/business/update-business-phone-numbers.js
1105
+ var updateBusinessPhoneNumbersMutation = `
1106
+ mutation UpdateBusinessPhoneNumbers($input: UpdateBusinessPhoneInput!) {
1107
+ updateBusinessPhone(input: $input) {
1108
+ business {
1109
+ info {
1110
+ phone {
1111
+ landline
1112
+ mobile
1113
+ }
1114
+ }
1115
+ }
1116
+ }
1117
+ }
1118
+ `;
1119
+
1120
+ // src/mutations/business/update-business-registration-numbers.js
1121
+ var updateBusinessRegistrationNumbersMutation = `
1122
+ mutation UpdateBusinessRegistrationNumbers($input: UpdateBusinessRegistrationNumbersInput!) {
1123
+ updateBusinessRegistrationNumbers(input: $input) {
1124
+ business {
1125
+ info {
1126
+ registrationNumbers {
1127
+ companiesHouse
1128
+ charityCommission
1052
1129
  }
1053
1130
  }
1054
1131
  }
1132
+ success
1055
1133
  }
1056
1134
  }
1057
1135
  `;
@@ -1070,40 +1148,26 @@ var updateBusinessVatMutation = `
1070
1148
  }
1071
1149
  `;
1072
1150
 
1073
- // src/mutations/personal/update-customer-details.js
1074
- var updateCustomerDetailsMutation = `
1075
- mutation UpdateCustomerAllFields($input: UpdateCustomerAllFieldsInput!) {
1076
- updateCustomerAllFields(input: $input) {
1077
- success
1151
+ // src/mutations/personal/update-customer-address.js
1152
+ var updateCustomerAddressMutation = `
1153
+ mutation UpdateCustomerAddress($input: UpdateCustomerAddressInput!) {
1154
+ updateCustomerAddress(input: $input) {
1078
1155
  customer {
1079
1156
  info {
1080
- name {
1081
- first
1082
- middle
1083
- last
1084
- }
1085
- dateOfBirth
1086
- phone {
1087
- mobile
1088
- landline
1089
- }
1090
- email {
1091
- address
1092
- }
1093
1157
  address {
1094
1158
  line1
1095
1159
  line2
1096
1160
  line3
1097
1161
  line4
1098
1162
  line5
1163
+ postalCode
1164
+ country
1165
+ city
1099
1166
  buildingNumberRange
1100
1167
  buildingName
1101
1168
  flatName
1102
1169
  street
1103
- city
1104
1170
  county
1105
- postalCode
1106
- country
1107
1171
  uprn
1108
1172
  }
1109
1173
  }
@@ -1112,55 +1176,92 @@ var updateCustomerDetailsMutation = `
1112
1176
  }
1113
1177
  `;
1114
1178
 
1115
- // src/mutations/business/update-business-legal-status.js
1116
- var updateBusinessLegalStatusMutation = `
1117
- mutation UpdateBusinessLegalStatus($input: UpdateBusinessLegalStatusInput!) {
1118
- updateBusinessLegalStatus(input: $input) {
1119
- business {
1179
+ // src/mutations/personal/update-customer-details.js
1180
+ var updateCustomerDetailsMutation = `
1181
+ mutation UpdateCustomerAllFields($input: UpdateCustomerAllFieldsInput!) {
1182
+ updateCustomerAllFields(input: $input) {
1183
+ success
1184
+ }
1185
+ }
1186
+ `;
1187
+
1188
+ // src/mutations/personal/update-customer-dob.js
1189
+ var updateCustomerDobMutation = `
1190
+ mutation UpdateCustomerDateOfBirth($input: UpdateCustomerDateOfBirthInput!) {
1191
+ updateCustomerDateOfBirth(input: $input) {
1192
+ customer {
1120
1193
  info {
1121
- legalStatus {
1122
- code
1123
- type
1124
- }
1194
+ dateOfBirth
1125
1195
  }
1126
1196
  }
1127
- success
1128
1197
  }
1129
1198
  }
1130
1199
  `;
1131
1200
 
1132
- // src/mutations/business/update-business-registration-numbers.js
1133
- var updateBusinessRegistrationNumbersMutation = `
1134
- mutation UpdateBusinessRegistrationNumbers($input: UpdateBusinessRegistrationNumbersInput!) {
1135
- updateBusinessRegistrationNumbers(input: $input) {
1136
- business {
1201
+ // src/mutations/personal/update-customer-email.js
1202
+ var updateCustomerEmailMutation = `
1203
+ mutation UpdateCustomerEmail($input: UpdateCustomerEmailInput!) {
1204
+ updateCustomerEmail(input: $input) {
1205
+ customer {
1137
1206
  info {
1138
- registrationNumbers {
1139
- companiesHouse
1140
- charityCommission
1207
+ email {
1208
+ address
1141
1209
  }
1142
1210
  }
1143
1211
  }
1144
- success
1145
1212
  }
1146
1213
  }
1147
1214
  `;
1148
1215
 
1149
- // src/mutations/mutations.js
1150
- var mutations = {
1151
- updateBusinessEmail: updateBusinessEmailMutation,
1216
+ // src/mutations/personal/update-customer-name.js
1217
+ var updateCustomerNameMutation = `
1218
+ mutation UpdateCustomerName($input: UpdateCustomerNameInput!) {
1219
+ updateCustomerName(input: $input) {
1220
+ customer {
1221
+ info {
1222
+ name {
1223
+ first
1224
+ last
1225
+ middle
1226
+ }
1227
+ }
1228
+ }
1229
+ }
1230
+ }
1231
+ `;
1232
+
1233
+ // src/mutations/personal/update-customer-phone.js
1234
+ var updateCustomerPhoneMutation = `
1235
+ mutation UpdateCustomerPhone($input: UpdateCustomerPhoneInput!) {
1236
+ updateCustomerPhone(input: $input) {
1237
+ customer {
1238
+ info {
1239
+ phone {
1240
+ landline
1241
+ mobile
1242
+ }
1243
+ }
1244
+ }
1245
+ }
1246
+ }
1247
+ `;
1248
+
1249
+ // src/mutations/mutations.js
1250
+ var mutations = {
1251
+ updateBusinessAddress: updateBusinessAddressMutation,
1252
+ updateBusinessDetails: updateBusinessDetailsMutation,
1253
+ updateBusinessEmail: updateBusinessEmailMutation,
1254
+ updateBusinessLegalStatus: updateBusinessLegalStatusMutation,
1152
1255
  updateBusinessName: updateBusinessNameMutation,
1153
1256
  updateBusinessPhoneNumbers: updateBusinessPhoneNumbersMutation,
1154
- updateBusinessAddress: updateBusinessAddressMutation,
1155
- updateCustomerName: updateCustomerNameMutation,
1156
- updateCustomerDob: updateCustomerDobMutation,
1157
- updateCustomerPhone: updateCustomerPhoneMutation,
1158
- updateCustomerEmail: updateCustomerEmailMutation,
1159
- updateCustomerAddress: updateCustomerAddressMutation,
1257
+ updateBusinessRegistrationNumbers: updateBusinessRegistrationNumbersMutation,
1160
1258
  updateBusinessVat: updateBusinessVatMutation,
1259
+ updateCustomerAddress: updateCustomerAddressMutation,
1161
1260
  updateCustomerDetails: updateCustomerDetailsMutation,
1162
- updateBusinessLegalStatus: updateBusinessLegalStatusMutation,
1163
- updateBusinessRegistrationNumbers: updateBusinessRegistrationNumbersMutation
1261
+ updateCustomerDob: updateCustomerDobMutation,
1262
+ updateCustomerEmail: updateCustomerEmailMutation,
1263
+ updateCustomerName: updateCustomerNameMutation,
1264
+ updateCustomerPhone: updateCustomerPhoneMutation
1164
1265
  };
1165
1266
 
1166
1267
  // src/presenters/base-presenter.js
@@ -1402,89 +1503,252 @@ var presenters = {
1402
1503
  addressChangeLink
1403
1504
  };
1404
1505
 
1405
- // src/utils/format-full-name.js
1406
- var formatFullName = (nameData) => {
1407
- return [
1408
- nameData.first,
1409
- nameData.middle,
1410
- nameData.last
1411
- ].filter(Boolean).join(" ");
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;
1412
1557
  };
1413
1558
 
1414
- // src/utils/format-validation-errors.js
1415
- var formatValidationErrors = (errors) => {
1416
- const formattedErrors = {};
1417
- errors.forEach((error) => {
1418
- const { type, context, message: text, path } = error;
1419
- if (Array.isArray(path) && path.length > 1) {
1420
- for (const field of path) {
1421
- if (!formattedErrors[field]) {
1422
- formattedErrors[field] = { text };
1423
- }
1424
- }
1425
- return;
1426
- }
1427
- if (type === "object.missing" && Array.isArray(context == null ? void 0 : context.peers)) {
1428
- context.peers.forEach((peer) => {
1429
- formattedErrors[peer] = { text };
1430
- });
1431
- return;
1432
- }
1433
- if (!formattedErrors[path[0]]) {
1434
- formattedErrors[path[0]] = { text };
1559
+ // src/services/build-fix-success-message-service.js
1560
+ var LABEL_MAPS = {
1561
+ personal: {
1562
+ name: "full name",
1563
+ email: "personal email address",
1564
+ phone: "personal phone numbers",
1565
+ dob: "date of birth",
1566
+ address: "personal address"
1567
+ },
1568
+ business: {
1569
+ name: "business name",
1570
+ email: "business email address",
1571
+ phone: "business phone numbers",
1572
+ vat: "business vat number",
1573
+ address: "business address"
1574
+ }
1575
+ };
1576
+ var PROPERTY_MAPS = {
1577
+ personal: {
1578
+ name: "changePersonalName",
1579
+ email: "changePersonalEmail",
1580
+ phone: "changePersonalPhoneNumbers",
1581
+ dob: "changePersonalDob",
1582
+ address: "changePersonalAddress"
1583
+ },
1584
+ business: {
1585
+ name: "changeBusinessName",
1586
+ email: "changeBusinessEmail",
1587
+ phone: "changeBusinessPhoneNumbers",
1588
+ vat: "changeBusinessVat",
1589
+ address: "changeBusinessAddress"
1590
+ }
1591
+ };
1592
+ var buildFixSuccessMessageService = (type, details) => {
1593
+ const { orderedSectionsToFix } = details;
1594
+ const changes = loopThroughSections(type, details, orderedSectionsToFix);
1595
+ if (changes.length === 0) {
1596
+ return null;
1597
+ }
1598
+ if (changes.length === 1) {
1599
+ return {
1600
+ type: "text",
1601
+ value: `You have updated your ${changes[0]}`
1602
+ };
1603
+ }
1604
+ return {
1605
+ type: "html",
1606
+ value: `
1607
+ <h3 class="govuk-notification-banner__heading">
1608
+ You have updated your:
1609
+ </h3>
1610
+ <ul class="govuk-list govuk-list--bullet">
1611
+ ${changes.map((change) => `<li>${change}</li>`).join("")}
1612
+ </ul>
1613
+ `
1614
+ };
1615
+ };
1616
+ var loopThroughSections = (type, details, orderedSectionsToFix) => {
1617
+ const changes = [];
1618
+ const labelMap = LABEL_MAPS[type];
1619
+ const propertyMap = PROPERTY_MAPS[type];
1620
+ for (const section of orderedSectionsToFix) {
1621
+ if (details[propertyMap[section]]) {
1622
+ changes.push(labelMap[section]);
1435
1623
  }
1436
- });
1437
- return formattedErrors;
1624
+ }
1625
+ return changes;
1438
1626
  };
1439
1627
 
1440
- // src/utils/build-update-business-email-variables.js
1441
- var buildUpdateBusinessEmailVariables = (email, sbi) => {
1442
- return { input: { email: { address: email }, sbi } };
1628
+ // src/services/business/build-business-fix-update-variables-service.js
1629
+ var buildBusinessFixUpdateVariablesService = (businessDetails) => {
1630
+ const { orderedSectionsToFix, sbi } = businessDetails;
1631
+ const input = { sbi };
1632
+ for (const applySection of sectionAppliers) {
1633
+ applySection(input, businessDetails, orderedSectionsToFix);
1634
+ }
1635
+ return { input };
1443
1636
  };
1444
-
1445
- // src/utils/build-update-business-name-variables.js
1446
- var buildUpdateBusinessNameVariables = (name, sbi) => {
1447
- return { input: { name, sbi } };
1637
+ var applyAddressSection = (input, businessDetails, orderedSectionsToFix) => {
1638
+ if (orderedSectionsToFix.includes("address") && businessDetails.changeBusinessAddress) {
1639
+ input.address = { withoutUprn: buildManualAddress(businessDetails.changeBusinessAddress) };
1640
+ }
1448
1641
  };
1449
-
1450
- // src/utils/build-update-business-phone-numbers-variables.js
1451
- var buildUpdateBusinessPhoneNumbersVariables = (businessTelephone, businessMobile, sbi) => {
1642
+ var applyEmailSection = (input, businessDetails, orderedSectionsToFix) => {
1643
+ if (orderedSectionsToFix.includes("email") && businessDetails.changeBusinessEmail) {
1644
+ Object.assign(input, buildEmailInput(businessDetails.changeBusinessEmail));
1645
+ }
1646
+ };
1647
+ var applyNameSection = (input, businessDetails, orderedSectionsToFix) => {
1648
+ if (orderedSectionsToFix.includes("name") && businessDetails.changeBusinessName) {
1649
+ input.name = businessDetails.changeBusinessName.businessName;
1650
+ }
1651
+ };
1652
+ var applyPhoneSection = (input, businessDetails, orderedSectionsToFix) => {
1653
+ if (orderedSectionsToFix.includes("phone") && businessDetails.changeBusinessPhoneNumbers) {
1654
+ Object.assign(input, buildPhoneInput(businessDetails.changeBusinessPhoneNumbers));
1655
+ }
1656
+ };
1657
+ var applyVatSection = (input, businessDetails, orderedSectionsToFix) => {
1658
+ if (orderedSectionsToFix.includes("vat") && businessDetails.changeBusinessVat) {
1659
+ input.vat = businessDetails.changeBusinessVat.vatNumber ?? "";
1660
+ }
1661
+ };
1662
+ var sectionAppliers = [
1663
+ applyAddressSection,
1664
+ applyEmailSection,
1665
+ applyNameSection,
1666
+ applyPhoneSection,
1667
+ applyVatSection
1668
+ ];
1669
+ var buildEmailInput = (change) => {
1452
1670
  return {
1453
- input: {
1454
- phone: {
1455
- landline: businessTelephone ?? null,
1456
- mobile: businessMobile ?? null
1457
- },
1458
- sbi
1671
+ email: {
1672
+ address: change.businessEmail
1459
1673
  }
1460
1674
  };
1461
1675
  };
1462
-
1463
- // src/utils/build-update-business-vat-variables.js
1464
- var buildUpdateBusinessVatVariables = (vat, sbi) => {
1676
+ var buildPhoneInput = (change) => {
1465
1677
  return {
1466
- input: {
1467
- vat,
1468
- sbi
1678
+ phone: {
1679
+ landline: change.businessTelephone ?? null,
1680
+ mobile: change.businessMobile ?? null
1469
1681
  }
1470
1682
  };
1471
1683
  };
1472
1684
 
1473
- // src/utils/utils.js
1474
- var utils = {
1475
- formatFullName,
1476
- formatValidationErrors,
1477
- buildUpdateBusinessEmailVariables,
1478
- buildUpdateBusinessNameVariables,
1479
- buildUpdateBusinessPhoneNumbersVariables,
1480
- buildUpdateBusinessVatVariables
1685
+ // src/services/check-interrupter-journey-session-service.js
1686
+ var checkInterrupterJourneySessionService = (yar, journeyKey) => {
1687
+ const sessionData = yar.get(journeyKey);
1688
+ if (!sessionData) {
1689
+ return false;
1690
+ }
1691
+ if (Array.isArray(sessionData.orderedSectionsToFix)) {
1692
+ return true;
1693
+ }
1694
+ return false;
1481
1695
  };
1482
1696
 
1483
- // src/services/os-places/address-lookup-service.js
1484
- import { placesAPI } from "osdatahub";
1485
-
1486
- // src/mock-data/mock-os-places-addresses.js
1487
- var mockAddresses = [
1697
+ // src/services/initialise-fix-journey-service.js
1698
+ var initialiseFixJourneyService = (yar, source, journeyType) => {
1699
+ let sessionKey;
1700
+ let sectionOrder = [];
1701
+ if (journeyType === "business") {
1702
+ sessionKey = "businessDetailsValidation";
1703
+ sectionOrder = BUSINESS_SECTION_ORDER;
1704
+ }
1705
+ if (journeyType === "personal") {
1706
+ sessionKey = "personalDetailsValidation";
1707
+ sectionOrder = PERSONAL_SECTION_ORDER;
1708
+ }
1709
+ const sessionData = yar.get(sessionKey);
1710
+ if (!(sessionData == null ? void 0 : sessionData.sectionsNeedingUpdate)) {
1711
+ return sessionData;
1712
+ }
1713
+ const orderedSectionsToFix = orderSectionsToFix(
1714
+ sessionData.sectionsNeedingUpdate,
1715
+ source,
1716
+ sectionOrder
1717
+ );
1718
+ updateSessionData(sessionData, source, orderedSectionsToFix);
1719
+ yar.set(sessionKey, sessionData);
1720
+ return sessionData;
1721
+ };
1722
+ var updateSessionData = (sessionData, source, orderedSectionsToFix) => {
1723
+ sessionData.orderedSectionsToFix = orderedSectionsToFix;
1724
+ delete sessionData.sectionsNeedingUpdate;
1725
+ delete sessionData.personalFixUpdates;
1726
+ delete sessionData.businessFixUpdates;
1727
+ if (source) {
1728
+ sessionData.source = source;
1729
+ }
1730
+ };
1731
+ var orderSectionsToFix = (sectionsNeedingUpdate, source, SECTION_ORDER) => {
1732
+ const sections = SECTION_ORDER.filter((section) => {
1733
+ return sectionsNeedingUpdate.includes(section);
1734
+ });
1735
+ if (!source) {
1736
+ return sections;
1737
+ }
1738
+ if (!SECTION_ORDER.includes(source)) {
1739
+ return sections;
1740
+ }
1741
+ return [
1742
+ source,
1743
+ ...sections.filter((section) => section !== source)
1744
+ ];
1745
+ };
1746
+
1747
+ // src/services/os-places/address-lookup-service.js
1748
+ import { placesAPI } from "osdatahub";
1749
+
1750
+ // src/mock-data/mock-os-places-addresses.js
1751
+ var mockAddresses = [
1488
1752
  {
1489
1753
  properties: {
1490
1754
  UPRN: "10000001",
@@ -1722,230 +1986,6 @@ var isRetryable = (error) => {
1722
1986
  return false;
1723
1987
  };
1724
1988
 
1725
- // src/services/build-address-variables-service.js
1726
- var buildUprnAddress = (change) => {
1727
- return {
1728
- pafOrganisationName: nullIfUndefined(change.pafOrganisationName),
1729
- buildingNumberRange: nullIfUndefined(change.buildingNumberRange),
1730
- buildingName: nullIfUndefined(change.buildingName),
1731
- flatName: nullIfUndefined(change.flatName),
1732
- street: nullIfUndefined(change.street),
1733
- city: nullIfUndefined(change.city),
1734
- county: nullIfUndefined(change.county),
1735
- postalCode: nullIfUndefined(change.postcode),
1736
- country: nullIfUndefined(change.country),
1737
- dependentLocality: nullIfUndefined(change.dependentLocality),
1738
- doubleDependentLocality: nullIfUndefined(change.doubleDependentLocality),
1739
- line1: null,
1740
- line2: null,
1741
- line3: null,
1742
- line4: null,
1743
- line5: null,
1744
- uprn: change.uprn
1745
- // required for DAL/v1
1746
- };
1747
- };
1748
- var buildManualAddress = (change) => {
1749
- return {
1750
- pafOrganisationName: null,
1751
- buildingNumberRange: null,
1752
- buildingName: null,
1753
- flatName: null,
1754
- street: null,
1755
- dependentLocality: null,
1756
- doubleDependentLocality: null,
1757
- county: null,
1758
- uprn: null,
1759
- line1: change.address1,
1760
- // required for DAL/v1
1761
- line2: nullIfUndefined(change.address2),
1762
- line3: nullIfUndefined(change.address3),
1763
- line4: nullIfUndefined(change.county),
1764
- // manual county mapped for validation
1765
- line5: null,
1766
- city: change.city,
1767
- // required for DAL/v1
1768
- postalCode: change.postcode,
1769
- // required for DAL/v1
1770
- country: change.country
1771
- // required for DAL/v1
1772
- };
1773
- };
1774
- var nullIfUndefined = (value) => {
1775
- return value ?? null;
1776
- };
1777
-
1778
- // src/services/check-interrupter-journey-session-service.js
1779
- var checkInterrupterJourneySessionService = (yar, journeyKey) => {
1780
- const sessionData = yar.get(journeyKey);
1781
- if (!sessionData) {
1782
- return false;
1783
- }
1784
- if (Array.isArray(sessionData.orderedSectionsToFix)) {
1785
- return true;
1786
- }
1787
- return false;
1788
- };
1789
-
1790
- // src/services/initialise-fix-journey-service.js
1791
- var initialiseFixJourneyService = (yar, source, journeyType) => {
1792
- let sessionKey;
1793
- let sectionOrder = [];
1794
- if (journeyType === "business") {
1795
- sessionKey = "businessDetailsValidation";
1796
- sectionOrder = BUSINESS_SECTION_ORDER;
1797
- }
1798
- if (journeyType === "personal") {
1799
- sessionKey = "personalDetailsValidation";
1800
- sectionOrder = PERSONAL_SECTION_ORDER;
1801
- }
1802
- const sessionData = yar.get(sessionKey);
1803
- if (!(sessionData == null ? void 0 : sessionData.sectionsNeedingUpdate)) {
1804
- return sessionData;
1805
- }
1806
- const orderedSectionsToFix = orderSectionsToFix(
1807
- sessionData.sectionsNeedingUpdate,
1808
- source,
1809
- sectionOrder
1810
- );
1811
- updateSessionData(sessionData, source, orderedSectionsToFix);
1812
- yar.set(sessionKey, sessionData);
1813
- return sessionData;
1814
- };
1815
- var updateSessionData = (sessionData, source, orderedSectionsToFix) => {
1816
- sessionData.orderedSectionsToFix = orderedSectionsToFix;
1817
- delete sessionData.sectionsNeedingUpdate;
1818
- delete sessionData.personalFixUpdates;
1819
- delete sessionData.businessFixUpdates;
1820
- if (source) {
1821
- sessionData.source = source;
1822
- }
1823
- };
1824
- var orderSectionsToFix = (sectionsNeedingUpdate, source, SECTION_ORDER) => {
1825
- const sections = SECTION_ORDER.filter((section) => {
1826
- return sectionsNeedingUpdate.includes(section);
1827
- });
1828
- if (!source) {
1829
- return sections;
1830
- }
1831
- if (!SECTION_ORDER.includes(source)) {
1832
- return sections;
1833
- }
1834
- return [
1835
- source,
1836
- ...sections.filter((section) => section !== source)
1837
- ];
1838
- };
1839
-
1840
- // src/services/validate-fix-details-service.js
1841
- var validateFixDetailsService = (payload, orderedSectionsToFix, schemas2) => {
1842
- const errors = [];
1843
- for (const section of orderedSectionsToFix) {
1844
- const schema = schemas2[section];
1845
- const result = schema.validate(payload, {
1846
- abortEarly: false,
1847
- allowUnknown: true
1848
- });
1849
- if (result.error) {
1850
- errors.push(...result.error.details);
1851
- }
1852
- }
1853
- if (errors.length > 0) {
1854
- return {
1855
- error: {
1856
- details: errors
1857
- }
1858
- };
1859
- }
1860
- return { value: payload };
1861
- };
1862
-
1863
- // src/services/set-fix-session-data-service.js
1864
- var setFixSessionDataService = (yar, sessionData, payload, journeyKey, updateKey) => {
1865
- const orderedSectionsToFix = sessionData.orderedSectionsToFix;
1866
- const type = journeyKey === "businessDetailsValidation" ? "business" : "personal";
1867
- const SECTION_FIELD_ORDER = type === "business" ? BUSINESS_SECTION_FIELD_ORDER : PERSONAL_SECTION_FIELD_ORDER;
1868
- const fixUpdates = {};
1869
- for (const section of orderedSectionsToFix) {
1870
- const fields = SECTION_FIELD_ORDER[section];
1871
- fixUpdates[section] = {};
1872
- for (const field of fields) {
1873
- fixUpdates[section][field] = payload[field] ?? "";
1874
- }
1875
- }
1876
- sessionData[updateKey] = fixUpdates;
1877
- yar.set(journeyKey, sessionData);
1878
- };
1879
-
1880
- // src/services/build-fix-success-message-service.js
1881
- var LABEL_MAPS = {
1882
- personal: {
1883
- name: "full name",
1884
- email: "personal email address",
1885
- phone: "personal phone numbers",
1886
- dob: "date of birth",
1887
- address: "personal address"
1888
- },
1889
- business: {
1890
- name: "business name",
1891
- email: "business email address",
1892
- phone: "business phone numbers",
1893
- vat: "business vat number",
1894
- address: "business address"
1895
- }
1896
- };
1897
- var PROPERTY_MAPS = {
1898
- personal: {
1899
- name: "changePersonalName",
1900
- email: "changePersonalEmail",
1901
- phone: "changePersonalPhoneNumbers",
1902
- dob: "changePersonalDob",
1903
- address: "changePersonalAddress"
1904
- },
1905
- business: {
1906
- name: "changeBusinessName",
1907
- email: "changeBusinessEmail",
1908
- phone: "changeBusinessPhoneNumbers",
1909
- vat: "changeBusinessVat",
1910
- address: "changeBusinessAddress"
1911
- }
1912
- };
1913
- var buildFixSuccessMessageService = (type, details) => {
1914
- const { orderedSectionsToFix } = details;
1915
- const changes = loopThroughSections(type, details, orderedSectionsToFix);
1916
- if (changes.length === 0) {
1917
- return null;
1918
- }
1919
- if (changes.length === 1) {
1920
- return {
1921
- type: "text",
1922
- value: `You have updated your ${changes[0]}`
1923
- };
1924
- }
1925
- return {
1926
- type: "html",
1927
- value: `
1928
- <h3 class="govuk-notification-banner__heading">
1929
- You have updated your:
1930
- </h3>
1931
- <ul class="govuk-list govuk-list--bullet">
1932
- ${changes.map((change) => `<li>${change}</li>`).join("")}
1933
- </ul>
1934
- `
1935
- };
1936
- };
1937
- var loopThroughSections = (type, details, orderedSectionsToFix) => {
1938
- const changes = [];
1939
- const labelMap = LABEL_MAPS[type];
1940
- const propertyMap = PROPERTY_MAPS[type];
1941
- for (const section of orderedSectionsToFix) {
1942
- if (details[propertyMap[section]]) {
1943
- changes.push(labelMap[section]);
1944
- }
1945
- }
1946
- return changes;
1947
- };
1948
-
1949
1989
  // src/services/personal/build-customer-fix-update-variables-service.js
1950
1990
  var buildCustomerFixUpdateVariablesService = (personalDetails) => {
1951
1991
  const { orderedSectionsToFix, crn } = personalDetails;
@@ -1954,10 +1994,10 @@ var buildCustomerFixUpdateVariablesService = (personalDetails) => {
1954
1994
  Object.assign(input, buildNameInput(personalDetails.changePersonalName));
1955
1995
  }
1956
1996
  if (orderedSectionsToFix.includes("email") && personalDetails.changePersonalEmail) {
1957
- Object.assign(input, buildEmailInput(personalDetails.changePersonalEmail));
1997
+ Object.assign(input, buildEmailInput2(personalDetails.changePersonalEmail));
1958
1998
  }
1959
1999
  if (orderedSectionsToFix.includes("phone") && personalDetails.changePersonalPhoneNumbers) {
1960
- Object.assign(input, buildPhoneInput(personalDetails.changePersonalPhoneNumbers));
2000
+ Object.assign(input, buildPhoneInput2(personalDetails.changePersonalPhoneNumbers));
1961
2001
  }
1962
2002
  if (orderedSectionsToFix.includes("dob") && personalDetails.changePersonalDob) {
1963
2003
  Object.assign(input, buildDobInput(personalDetails.changePersonalDob));
@@ -1967,7 +2007,7 @@ var buildCustomerFixUpdateVariablesService = (personalDetails) => {
1967
2007
  }
1968
2008
  return { input };
1969
2009
  };
1970
- var buildPhoneInput = (change) => {
2010
+ var buildPhoneInput2 = (change) => {
1971
2011
  return {
1972
2012
  phone: {
1973
2013
  landline: change.personalTelephone ?? null,
@@ -1975,7 +2015,7 @@ var buildPhoneInput = (change) => {
1975
2015
  }
1976
2016
  };
1977
2017
  };
1978
- var buildEmailInput = (change) => {
2018
+ var buildEmailInput2 = (change) => {
1979
2019
  return {
1980
2020
  email: {
1981
2021
  address: change.personalEmail
@@ -1997,17 +2037,58 @@ var buildDobInput = (change) => {
1997
2037
  };
1998
2038
  };
1999
2039
 
2040
+ // src/services/set-fix-session-data-service.js
2041
+ var setFixSessionDataService = (yar, sessionData, payload, journeyKey, updateKey) => {
2042
+ const orderedSectionsToFix = sessionData.orderedSectionsToFix;
2043
+ const type = journeyKey === "businessDetailsValidation" ? "business" : "personal";
2044
+ const SECTION_FIELD_ORDER = type === "business" ? BUSINESS_SECTION_FIELD_ORDER : PERSONAL_SECTION_FIELD_ORDER;
2045
+ const fixUpdates = {};
2046
+ for (const section of orderedSectionsToFix) {
2047
+ const fields = SECTION_FIELD_ORDER[section];
2048
+ fixUpdates[section] = {};
2049
+ for (const field of fields) {
2050
+ fixUpdates[section][field] = payload[field] ?? "";
2051
+ }
2052
+ }
2053
+ sessionData[updateKey] = fixUpdates;
2054
+ yar.set(journeyKey, sessionData);
2055
+ };
2056
+
2057
+ // src/services/validate-fix-details-service.js
2058
+ var validateFixDetailsService = (payload, orderedSectionsToFix, schemas2) => {
2059
+ const errors = [];
2060
+ for (const section of orderedSectionsToFix) {
2061
+ const schema = schemas2[section];
2062
+ const result = schema.validate(payload, {
2063
+ abortEarly: false,
2064
+ allowUnknown: true
2065
+ });
2066
+ if (result.error) {
2067
+ errors.push(...result.error.details);
2068
+ }
2069
+ }
2070
+ if (errors.length > 0) {
2071
+ return {
2072
+ error: {
2073
+ details: errors
2074
+ }
2075
+ };
2076
+ }
2077
+ return { value: payload };
2078
+ };
2079
+
2000
2080
  // src/services/services.js
2001
2081
  var services = {
2002
2082
  addressLookup: addressLookupService,
2003
- buildUprnAddress,
2083
+ buildBusinessFixUpdateVariables: buildBusinessFixUpdateVariablesService,
2084
+ buildCustomerFixUpdateVariables: buildCustomerFixUpdateVariablesService,
2085
+ buildFixSuccessMessage: buildFixSuccessMessageService,
2004
2086
  buildManualAddress,
2087
+ buildUprnAddress,
2005
2088
  checkInterrupterJourneySession: checkInterrupterJourneySessionService,
2006
2089
  initialiseFixJourney: initialiseFixJourneyService,
2007
- validateFixDetails: validateFixDetailsService,
2008
2090
  setFixSessionData: setFixSessionDataService,
2009
- buildFixSuccessMessage: buildFixSuccessMessageService,
2010
- buildCustomerFixUpdateVariables: buildCustomerFixUpdateVariablesService
2091
+ validateFixDetails: validateFixDetailsService
2011
2092
  };
2012
2093
  export {
2013
2094
  constants,