@defra/fcp-sfd-frontend-engine 0.19.0 → 0.21.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 +151 -5
- package/dist/index.js +151 -5
- package/package.json +1 -1
- package/src/constants/index.js +7 -2
- package/src/constants/success-messages.js +1 -0
- package/src/mutations/business/update-business-address.js +26 -0
- package/src/mutations/business/update-business-email.js +1 -1
- package/src/mutations/business/update-business-phone-numbers.js +14 -0
- package/src/mutations/mutations.js +7 -1
- package/src/mutations/personal/update-customer-address.js +26 -0
- package/src/services/build-address-variables-service.js +107 -0
- package/src/services/services.js +4 -1
- package/src/utils/build-update-business-phone-numbers-variables.js +20 -0
- package/src/utils/utils.js +3 -1
package/dist/index.cjs
CHANGED
|
@@ -100,6 +100,7 @@ var MONTH_MAP = {
|
|
|
100
100
|
// src/constants/success-messages.js
|
|
101
101
|
var BUSINESS_EMAIL_ADDRESS = "You have updated your business email address";
|
|
102
102
|
var BUSINESS_NAME = "You have updated your business name";
|
|
103
|
+
var BUSINESS_PHONE_NUMBERS = "You have updated your business phone numbers";
|
|
103
104
|
|
|
104
105
|
// src/constants/index.js
|
|
105
106
|
var constants = {
|
|
@@ -136,7 +137,8 @@ var constants = {
|
|
|
136
137
|
monthMap: MONTH_MAP,
|
|
137
138
|
successMessages: {
|
|
138
139
|
BUSINESS_EMAIL_ADDRESS,
|
|
139
|
-
BUSINESS_NAME
|
|
140
|
+
BUSINESS_NAME,
|
|
141
|
+
BUSINESS_PHONE_NUMBERS
|
|
140
142
|
}
|
|
141
143
|
};
|
|
142
144
|
|
|
@@ -704,7 +706,7 @@ var mappers = {
|
|
|
704
706
|
|
|
705
707
|
// src/mutations/business/update-business-email.js
|
|
706
708
|
var updateBusinessEmailMutation = `
|
|
707
|
-
mutation
|
|
709
|
+
mutation UpdateBusinessEmail($input: UpdateBusinessEmailInput!) {
|
|
708
710
|
updateBusinessEmail(input: $input) {
|
|
709
711
|
business {
|
|
710
712
|
info {
|
|
@@ -732,6 +734,22 @@ var updateBusinessNameMutation = `
|
|
|
732
734
|
}
|
|
733
735
|
`;
|
|
734
736
|
|
|
737
|
+
// src/mutations/business/update-business-phone-numbers.js
|
|
738
|
+
var updateBusinessPhoneNumbersMutation = `
|
|
739
|
+
mutation UpdateBusinessPhoneNumbers($input: UpdateBusinessPhoneNumbersInput!) {
|
|
740
|
+
updateBusinessPhone(input: $input) {
|
|
741
|
+
business {
|
|
742
|
+
info {
|
|
743
|
+
phone {
|
|
744
|
+
landline
|
|
745
|
+
mobile
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
`;
|
|
752
|
+
|
|
735
753
|
// src/mutations/personal/update-customer-name.js
|
|
736
754
|
var updateCustomerNameMutation = `
|
|
737
755
|
mutation UpdateCustomerName($input: UpdateCustomerNameInput!) {
|
|
@@ -793,14 +811,73 @@ var updateCustomerEmailMutation = `
|
|
|
793
811
|
}
|
|
794
812
|
`;
|
|
795
813
|
|
|
814
|
+
// src/mutations/personal/update-customer-address.js
|
|
815
|
+
var updateCustomerAddressMutation = `
|
|
816
|
+
mutation UpdateCustomerAddress($input: UpdateCustomerAddressInput!) {
|
|
817
|
+
updateCustomerAddress(input: $input) {
|
|
818
|
+
customer {
|
|
819
|
+
info {
|
|
820
|
+
address {
|
|
821
|
+
line1
|
|
822
|
+
line2
|
|
823
|
+
line3
|
|
824
|
+
line4
|
|
825
|
+
line5
|
|
826
|
+
postalCode
|
|
827
|
+
country
|
|
828
|
+
city
|
|
829
|
+
buildingNumberRange
|
|
830
|
+
buildingName
|
|
831
|
+
flatName
|
|
832
|
+
street
|
|
833
|
+
county
|
|
834
|
+
uprn
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
}
|
|
839
|
+
}
|
|
840
|
+
`;
|
|
841
|
+
|
|
842
|
+
// src/mutations/business/update-business-address.js
|
|
843
|
+
var updateBusinessAddressMutation = `
|
|
844
|
+
mutation UpdateBusinessAddress($input: UpdateBusinessAddressInput!) {
|
|
845
|
+
updateBusinessAddress(input: $input) {
|
|
846
|
+
business {
|
|
847
|
+
info {
|
|
848
|
+
address {
|
|
849
|
+
line1
|
|
850
|
+
line2
|
|
851
|
+
line3
|
|
852
|
+
line4
|
|
853
|
+
line5
|
|
854
|
+
postalCode
|
|
855
|
+
country
|
|
856
|
+
city
|
|
857
|
+
buildingNumberRange
|
|
858
|
+
buildingName
|
|
859
|
+
flatName
|
|
860
|
+
street
|
|
861
|
+
county
|
|
862
|
+
uprn
|
|
863
|
+
}
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
`;
|
|
869
|
+
|
|
796
870
|
// src/mutations/mutations.js
|
|
797
871
|
var mutations = {
|
|
798
872
|
updateBusinessEmail: updateBusinessEmailMutation,
|
|
799
873
|
updateBusinessName: updateBusinessNameMutation,
|
|
874
|
+
updateBusinessPhoneNumbers: updateBusinessPhoneNumbersMutation,
|
|
875
|
+
updateBusinessAddress: updateBusinessAddressMutation,
|
|
800
876
|
updateCustomerName: updateCustomerNameMutation,
|
|
801
877
|
updateCustomerDob: updateCustomerDobMutation,
|
|
802
878
|
updateCustomerPhone: updateCustomerPhoneMutation,
|
|
803
|
-
updateCustomerEmail: updateCustomerEmailMutation
|
|
879
|
+
updateCustomerEmail: updateCustomerEmailMutation,
|
|
880
|
+
updateCustomerAddress: updateCustomerAddressMutation
|
|
804
881
|
};
|
|
805
882
|
|
|
806
883
|
// src/presenters/base-presenter.js
|
|
@@ -1071,12 +1148,26 @@ var buildUpdateBusinessNameVariables = (name, sbi) => {
|
|
|
1071
1148
|
return { input: { name, sbi } };
|
|
1072
1149
|
};
|
|
1073
1150
|
|
|
1151
|
+
// src/utils/build-update-business-phone-numbers-variables.js
|
|
1152
|
+
var buildUpdateBusinessPhoneNumbersVariables = (businessTelephone, businessMobile, sbi) => {
|
|
1153
|
+
return {
|
|
1154
|
+
input: {
|
|
1155
|
+
phone: {
|
|
1156
|
+
landline: businessTelephone ?? null,
|
|
1157
|
+
mobile: businessMobile ?? null
|
|
1158
|
+
},
|
|
1159
|
+
sbi
|
|
1160
|
+
}
|
|
1161
|
+
};
|
|
1162
|
+
};
|
|
1163
|
+
|
|
1074
1164
|
// src/utils/utils.js
|
|
1075
1165
|
var utils = {
|
|
1076
1166
|
formatFullName,
|
|
1077
1167
|
formatValidationErrors,
|
|
1078
1168
|
buildUpdateBusinessEmailVariables,
|
|
1079
|
-
buildUpdateBusinessNameVariables
|
|
1169
|
+
buildUpdateBusinessNameVariables,
|
|
1170
|
+
buildUpdateBusinessPhoneNumbersVariables
|
|
1080
1171
|
};
|
|
1081
1172
|
|
|
1082
1173
|
// src/services/os-places/address-lookup-service.js
|
|
@@ -1321,9 +1412,64 @@ var isRetryable = (error) => {
|
|
|
1321
1412
|
return false;
|
|
1322
1413
|
};
|
|
1323
1414
|
|
|
1415
|
+
// src/services/build-address-variables-service.js
|
|
1416
|
+
var buildUprnAddress = (change) => {
|
|
1417
|
+
return {
|
|
1418
|
+
pafOrganisationName: nullIfUndefined(change.pafOrganisationName),
|
|
1419
|
+
buildingNumberRange: nullIfUndefined(change.buildingNumberRange),
|
|
1420
|
+
buildingName: nullIfUndefined(change.buildingName),
|
|
1421
|
+
flatName: nullIfUndefined(change.flatName),
|
|
1422
|
+
street: nullIfUndefined(change.street),
|
|
1423
|
+
city: nullIfUndefined(change.city),
|
|
1424
|
+
county: nullIfUndefined(change.county),
|
|
1425
|
+
postalCode: nullIfUndefined(change.postcode),
|
|
1426
|
+
country: nullIfUndefined(change.country),
|
|
1427
|
+
dependentLocality: nullIfUndefined(change.dependentLocality),
|
|
1428
|
+
doubleDependentLocality: nullIfUndefined(change.doubleDependentLocality),
|
|
1429
|
+
line1: null,
|
|
1430
|
+
line2: null,
|
|
1431
|
+
line3: null,
|
|
1432
|
+
line4: null,
|
|
1433
|
+
line5: null,
|
|
1434
|
+
uprn: change.uprn
|
|
1435
|
+
// required for DAL/v1
|
|
1436
|
+
};
|
|
1437
|
+
};
|
|
1438
|
+
var buildManualAddress = (change) => {
|
|
1439
|
+
return {
|
|
1440
|
+
pafOrganisationName: null,
|
|
1441
|
+
buildingNumberRange: null,
|
|
1442
|
+
buildingName: null,
|
|
1443
|
+
flatName: null,
|
|
1444
|
+
street: null,
|
|
1445
|
+
dependentLocality: null,
|
|
1446
|
+
doubleDependentLocality: null,
|
|
1447
|
+
county: null,
|
|
1448
|
+
uprn: null,
|
|
1449
|
+
line1: change.address1,
|
|
1450
|
+
// required for DAL/v1
|
|
1451
|
+
line2: nullIfUndefined(change.address2),
|
|
1452
|
+
line3: nullIfUndefined(change.address3),
|
|
1453
|
+
line4: nullIfUndefined(change.county),
|
|
1454
|
+
// manual county mapped for validation
|
|
1455
|
+
line5: null,
|
|
1456
|
+
city: change.city,
|
|
1457
|
+
// required for DAL/v1
|
|
1458
|
+
postalCode: change.postcode,
|
|
1459
|
+
// required for DAL/v1
|
|
1460
|
+
country: change.country
|
|
1461
|
+
// required for DAL/v1
|
|
1462
|
+
};
|
|
1463
|
+
};
|
|
1464
|
+
var nullIfUndefined = (value) => {
|
|
1465
|
+
return value ?? null;
|
|
1466
|
+
};
|
|
1467
|
+
|
|
1324
1468
|
// src/services/services.js
|
|
1325
1469
|
var services = {
|
|
1326
|
-
addressLookup: addressLookupService
|
|
1470
|
+
addressLookup: addressLookupService,
|
|
1471
|
+
buildUprnAddress,
|
|
1472
|
+
buildManualAddress
|
|
1327
1473
|
};
|
|
1328
1474
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1329
1475
|
0 && (module.exports = {
|
package/dist/index.js
CHANGED
|
@@ -59,6 +59,7 @@ var MONTH_MAP = {
|
|
|
59
59
|
// src/constants/success-messages.js
|
|
60
60
|
var BUSINESS_EMAIL_ADDRESS = "You have updated your business email address";
|
|
61
61
|
var BUSINESS_NAME = "You have updated your business name";
|
|
62
|
+
var BUSINESS_PHONE_NUMBERS = "You have updated your business phone numbers";
|
|
62
63
|
|
|
63
64
|
// src/constants/index.js
|
|
64
65
|
var constants = {
|
|
@@ -95,7 +96,8 @@ var constants = {
|
|
|
95
96
|
monthMap: MONTH_MAP,
|
|
96
97
|
successMessages: {
|
|
97
98
|
BUSINESS_EMAIL_ADDRESS,
|
|
98
|
-
BUSINESS_NAME
|
|
99
|
+
BUSINESS_NAME,
|
|
100
|
+
BUSINESS_PHONE_NUMBERS
|
|
99
101
|
}
|
|
100
102
|
};
|
|
101
103
|
|
|
@@ -663,7 +665,7 @@ var mappers = {
|
|
|
663
665
|
|
|
664
666
|
// src/mutations/business/update-business-email.js
|
|
665
667
|
var updateBusinessEmailMutation = `
|
|
666
|
-
mutation
|
|
668
|
+
mutation UpdateBusinessEmail($input: UpdateBusinessEmailInput!) {
|
|
667
669
|
updateBusinessEmail(input: $input) {
|
|
668
670
|
business {
|
|
669
671
|
info {
|
|
@@ -691,6 +693,22 @@ var updateBusinessNameMutation = `
|
|
|
691
693
|
}
|
|
692
694
|
`;
|
|
693
695
|
|
|
696
|
+
// src/mutations/business/update-business-phone-numbers.js
|
|
697
|
+
var updateBusinessPhoneNumbersMutation = `
|
|
698
|
+
mutation UpdateBusinessPhoneNumbers($input: UpdateBusinessPhoneNumbersInput!) {
|
|
699
|
+
updateBusinessPhone(input: $input) {
|
|
700
|
+
business {
|
|
701
|
+
info {
|
|
702
|
+
phone {
|
|
703
|
+
landline
|
|
704
|
+
mobile
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
}
|
|
710
|
+
`;
|
|
711
|
+
|
|
694
712
|
// src/mutations/personal/update-customer-name.js
|
|
695
713
|
var updateCustomerNameMutation = `
|
|
696
714
|
mutation UpdateCustomerName($input: UpdateCustomerNameInput!) {
|
|
@@ -752,14 +770,73 @@ var updateCustomerEmailMutation = `
|
|
|
752
770
|
}
|
|
753
771
|
`;
|
|
754
772
|
|
|
773
|
+
// src/mutations/personal/update-customer-address.js
|
|
774
|
+
var updateCustomerAddressMutation = `
|
|
775
|
+
mutation UpdateCustomerAddress($input: UpdateCustomerAddressInput!) {
|
|
776
|
+
updateCustomerAddress(input: $input) {
|
|
777
|
+
customer {
|
|
778
|
+
info {
|
|
779
|
+
address {
|
|
780
|
+
line1
|
|
781
|
+
line2
|
|
782
|
+
line3
|
|
783
|
+
line4
|
|
784
|
+
line5
|
|
785
|
+
postalCode
|
|
786
|
+
country
|
|
787
|
+
city
|
|
788
|
+
buildingNumberRange
|
|
789
|
+
buildingName
|
|
790
|
+
flatName
|
|
791
|
+
street
|
|
792
|
+
county
|
|
793
|
+
uprn
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
`;
|
|
800
|
+
|
|
801
|
+
// src/mutations/business/update-business-address.js
|
|
802
|
+
var updateBusinessAddressMutation = `
|
|
803
|
+
mutation UpdateBusinessAddress($input: UpdateBusinessAddressInput!) {
|
|
804
|
+
updateBusinessAddress(input: $input) {
|
|
805
|
+
business {
|
|
806
|
+
info {
|
|
807
|
+
address {
|
|
808
|
+
line1
|
|
809
|
+
line2
|
|
810
|
+
line3
|
|
811
|
+
line4
|
|
812
|
+
line5
|
|
813
|
+
postalCode
|
|
814
|
+
country
|
|
815
|
+
city
|
|
816
|
+
buildingNumberRange
|
|
817
|
+
buildingName
|
|
818
|
+
flatName
|
|
819
|
+
street
|
|
820
|
+
county
|
|
821
|
+
uprn
|
|
822
|
+
}
|
|
823
|
+
}
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
`;
|
|
828
|
+
|
|
755
829
|
// src/mutations/mutations.js
|
|
756
830
|
var mutations = {
|
|
757
831
|
updateBusinessEmail: updateBusinessEmailMutation,
|
|
758
832
|
updateBusinessName: updateBusinessNameMutation,
|
|
833
|
+
updateBusinessPhoneNumbers: updateBusinessPhoneNumbersMutation,
|
|
834
|
+
updateBusinessAddress: updateBusinessAddressMutation,
|
|
759
835
|
updateCustomerName: updateCustomerNameMutation,
|
|
760
836
|
updateCustomerDob: updateCustomerDobMutation,
|
|
761
837
|
updateCustomerPhone: updateCustomerPhoneMutation,
|
|
762
|
-
updateCustomerEmail: updateCustomerEmailMutation
|
|
838
|
+
updateCustomerEmail: updateCustomerEmailMutation,
|
|
839
|
+
updateCustomerAddress: updateCustomerAddressMutation
|
|
763
840
|
};
|
|
764
841
|
|
|
765
842
|
// src/presenters/base-presenter.js
|
|
@@ -1030,12 +1107,26 @@ var buildUpdateBusinessNameVariables = (name, sbi) => {
|
|
|
1030
1107
|
return { input: { name, sbi } };
|
|
1031
1108
|
};
|
|
1032
1109
|
|
|
1110
|
+
// src/utils/build-update-business-phone-numbers-variables.js
|
|
1111
|
+
var buildUpdateBusinessPhoneNumbersVariables = (businessTelephone, businessMobile, sbi) => {
|
|
1112
|
+
return {
|
|
1113
|
+
input: {
|
|
1114
|
+
phone: {
|
|
1115
|
+
landline: businessTelephone ?? null,
|
|
1116
|
+
mobile: businessMobile ?? null
|
|
1117
|
+
},
|
|
1118
|
+
sbi
|
|
1119
|
+
}
|
|
1120
|
+
};
|
|
1121
|
+
};
|
|
1122
|
+
|
|
1033
1123
|
// src/utils/utils.js
|
|
1034
1124
|
var utils = {
|
|
1035
1125
|
formatFullName,
|
|
1036
1126
|
formatValidationErrors,
|
|
1037
1127
|
buildUpdateBusinessEmailVariables,
|
|
1038
|
-
buildUpdateBusinessNameVariables
|
|
1128
|
+
buildUpdateBusinessNameVariables,
|
|
1129
|
+
buildUpdateBusinessPhoneNumbersVariables
|
|
1039
1130
|
};
|
|
1040
1131
|
|
|
1041
1132
|
// src/services/os-places/address-lookup-service.js
|
|
@@ -1280,9 +1371,64 @@ var isRetryable = (error) => {
|
|
|
1280
1371
|
return false;
|
|
1281
1372
|
};
|
|
1282
1373
|
|
|
1374
|
+
// src/services/build-address-variables-service.js
|
|
1375
|
+
var buildUprnAddress = (change) => {
|
|
1376
|
+
return {
|
|
1377
|
+
pafOrganisationName: nullIfUndefined(change.pafOrganisationName),
|
|
1378
|
+
buildingNumberRange: nullIfUndefined(change.buildingNumberRange),
|
|
1379
|
+
buildingName: nullIfUndefined(change.buildingName),
|
|
1380
|
+
flatName: nullIfUndefined(change.flatName),
|
|
1381
|
+
street: nullIfUndefined(change.street),
|
|
1382
|
+
city: nullIfUndefined(change.city),
|
|
1383
|
+
county: nullIfUndefined(change.county),
|
|
1384
|
+
postalCode: nullIfUndefined(change.postcode),
|
|
1385
|
+
country: nullIfUndefined(change.country),
|
|
1386
|
+
dependentLocality: nullIfUndefined(change.dependentLocality),
|
|
1387
|
+
doubleDependentLocality: nullIfUndefined(change.doubleDependentLocality),
|
|
1388
|
+
line1: null,
|
|
1389
|
+
line2: null,
|
|
1390
|
+
line3: null,
|
|
1391
|
+
line4: null,
|
|
1392
|
+
line5: null,
|
|
1393
|
+
uprn: change.uprn
|
|
1394
|
+
// required for DAL/v1
|
|
1395
|
+
};
|
|
1396
|
+
};
|
|
1397
|
+
var buildManualAddress = (change) => {
|
|
1398
|
+
return {
|
|
1399
|
+
pafOrganisationName: null,
|
|
1400
|
+
buildingNumberRange: null,
|
|
1401
|
+
buildingName: null,
|
|
1402
|
+
flatName: null,
|
|
1403
|
+
street: null,
|
|
1404
|
+
dependentLocality: null,
|
|
1405
|
+
doubleDependentLocality: null,
|
|
1406
|
+
county: null,
|
|
1407
|
+
uprn: null,
|
|
1408
|
+
line1: change.address1,
|
|
1409
|
+
// required for DAL/v1
|
|
1410
|
+
line2: nullIfUndefined(change.address2),
|
|
1411
|
+
line3: nullIfUndefined(change.address3),
|
|
1412
|
+
line4: nullIfUndefined(change.county),
|
|
1413
|
+
// manual county mapped for validation
|
|
1414
|
+
line5: null,
|
|
1415
|
+
city: change.city,
|
|
1416
|
+
// required for DAL/v1
|
|
1417
|
+
postalCode: change.postcode,
|
|
1418
|
+
// required for DAL/v1
|
|
1419
|
+
country: change.country
|
|
1420
|
+
// required for DAL/v1
|
|
1421
|
+
};
|
|
1422
|
+
};
|
|
1423
|
+
var nullIfUndefined = (value) => {
|
|
1424
|
+
return value ?? null;
|
|
1425
|
+
};
|
|
1426
|
+
|
|
1283
1427
|
// src/services/services.js
|
|
1284
1428
|
var services = {
|
|
1285
|
-
addressLookup: addressLookupService
|
|
1429
|
+
addressLookup: addressLookupService,
|
|
1430
|
+
buildUprnAddress,
|
|
1431
|
+
buildManualAddress
|
|
1286
1432
|
};
|
|
1287
1433
|
export {
|
|
1288
1434
|
constants,
|
package/package.json
CHANGED
package/src/constants/index.js
CHANGED
|
@@ -33,7 +33,11 @@ import { PHONE_NUMBER_PATTERN, NO_CONTROL_CHARS_PATTERN } from './patterns.js'
|
|
|
33
33
|
import { MONTH_MAP } from './month-map.js'
|
|
34
34
|
|
|
35
35
|
// Success messages
|
|
36
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
BUSINESS_EMAIL_ADDRESS,
|
|
38
|
+
BUSINESS_NAME,
|
|
39
|
+
BUSINESS_PHONE_NUMBERS
|
|
40
|
+
} from './success-messages.js'
|
|
37
41
|
|
|
38
42
|
export const constants = {
|
|
39
43
|
statusCodes: {
|
|
@@ -69,6 +73,7 @@ export const constants = {
|
|
|
69
73
|
monthMap: MONTH_MAP,
|
|
70
74
|
successMessages: {
|
|
71
75
|
BUSINESS_EMAIL_ADDRESS,
|
|
72
|
-
BUSINESS_NAME
|
|
76
|
+
BUSINESS_NAME,
|
|
77
|
+
BUSINESS_PHONE_NUMBERS
|
|
73
78
|
}
|
|
74
79
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const updateBusinessAddressMutation = `
|
|
2
|
+
mutation UpdateBusinessAddress($input: UpdateBusinessAddressInput!) {
|
|
3
|
+
updateBusinessAddress(input: $input) {
|
|
4
|
+
business {
|
|
5
|
+
info {
|
|
6
|
+
address {
|
|
7
|
+
line1
|
|
8
|
+
line2
|
|
9
|
+
line3
|
|
10
|
+
line4
|
|
11
|
+
line5
|
|
12
|
+
postalCode
|
|
13
|
+
country
|
|
14
|
+
city
|
|
15
|
+
buildingNumberRange
|
|
16
|
+
buildingName
|
|
17
|
+
flatName
|
|
18
|
+
street
|
|
19
|
+
county
|
|
20
|
+
uprn
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const updateBusinessPhoneNumbersMutation = `
|
|
2
|
+
mutation UpdateBusinessPhoneNumbers($input: UpdateBusinessPhoneNumbersInput!) {
|
|
3
|
+
updateBusinessPhone(input: $input) {
|
|
4
|
+
business {
|
|
5
|
+
info {
|
|
6
|
+
phone {
|
|
7
|
+
landline
|
|
8
|
+
mobile
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
`
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { updateBusinessEmailMutation } from './business/update-business-email.js'
|
|
2
2
|
import { updateBusinessNameMutation } from './business/update-business-name.js'
|
|
3
|
+
import { updateBusinessPhoneNumbersMutation } from './business/update-business-phone-numbers.js'
|
|
3
4
|
import { updateCustomerNameMutation } from './personal/update-customer-name.js'
|
|
4
5
|
import { updateCustomerDobMutation } from './personal/update-customer-dob.js'
|
|
5
6
|
import { updateCustomerPhoneMutation } from './personal/update-customer-phone.js'
|
|
6
7
|
import { updateCustomerEmailMutation } from './personal/update-customer-email.js'
|
|
8
|
+
import { updateCustomerAddressMutation } from './personal/update-customer-address.js'
|
|
9
|
+
import { updateBusinessAddressMutation } from './business/update-business-address.js'
|
|
7
10
|
|
|
8
11
|
export const mutations = {
|
|
9
12
|
updateBusinessEmail: updateBusinessEmailMutation,
|
|
10
13
|
updateBusinessName: updateBusinessNameMutation,
|
|
14
|
+
updateBusinessPhoneNumbers: updateBusinessPhoneNumbersMutation,
|
|
15
|
+
updateBusinessAddress: updateBusinessAddressMutation,
|
|
11
16
|
updateCustomerName: updateCustomerNameMutation,
|
|
12
17
|
updateCustomerDob: updateCustomerDobMutation,
|
|
13
18
|
updateCustomerPhone: updateCustomerPhoneMutation,
|
|
14
|
-
updateCustomerEmail: updateCustomerEmailMutation
|
|
19
|
+
updateCustomerEmail: updateCustomerEmailMutation,
|
|
20
|
+
updateCustomerAddress: updateCustomerAddressMutation
|
|
15
21
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const updateCustomerAddressMutation = `
|
|
2
|
+
mutation UpdateCustomerAddress($input: UpdateCustomerAddressInput!) {
|
|
3
|
+
updateCustomerAddress(input: $input) {
|
|
4
|
+
customer {
|
|
5
|
+
info {
|
|
6
|
+
address {
|
|
7
|
+
line1
|
|
8
|
+
line2
|
|
9
|
+
line3
|
|
10
|
+
line4
|
|
11
|
+
line5
|
|
12
|
+
postalCode
|
|
13
|
+
country
|
|
14
|
+
city
|
|
15
|
+
buildingNumberRange
|
|
16
|
+
buildingName
|
|
17
|
+
flatName
|
|
18
|
+
street
|
|
19
|
+
county
|
|
20
|
+
uprn
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
`
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service to build address variables for DAL mutations
|
|
3
|
+
*
|
|
4
|
+
* Supports both postcode lookup (with UPRN) and manually entered addresses.
|
|
5
|
+
* Handles normalization of optional fields, city, county, PO BOX, dependentLocality,
|
|
6
|
+
* and doubleDependentLocality. Returns an address object ready for the DAL mutation.
|
|
7
|
+
*
|
|
8
|
+
* @module buildAddressVariablesService
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Builds address variables for an address chosen via postcode lookup (with UPRN).
|
|
13
|
+
* When a UPRN is present, it is the only required field. The rest of the address
|
|
14
|
+
* data is included but the DAL/v1 does not apply further validation.
|
|
15
|
+
*
|
|
16
|
+
* Optional fields are normalized using nullIfUndefined to ensure they are
|
|
17
|
+
* explicitly set to `null` rather than being left `undefined`.
|
|
18
|
+
*
|
|
19
|
+
* @param {Object} change - The address change object containing UPRN and address fields
|
|
20
|
+
* @returns {Object} Address object formatted for DAL/v1 with UPRN
|
|
21
|
+
*/
|
|
22
|
+
const buildUprnAddress = (change) => {
|
|
23
|
+
return {
|
|
24
|
+
pafOrganisationName: nullIfUndefined(change.pafOrganisationName),
|
|
25
|
+
buildingNumberRange: nullIfUndefined(change.buildingNumberRange),
|
|
26
|
+
buildingName: nullIfUndefined(change.buildingName),
|
|
27
|
+
flatName: nullIfUndefined(change.flatName),
|
|
28
|
+
street: nullIfUndefined(change.street),
|
|
29
|
+
city: nullIfUndefined(change.city),
|
|
30
|
+
county: nullIfUndefined(change.county),
|
|
31
|
+
postalCode: nullIfUndefined(change.postcode),
|
|
32
|
+
country: nullIfUndefined(change.country),
|
|
33
|
+
dependentLocality: nullIfUndefined(change.dependentLocality),
|
|
34
|
+
doubleDependentLocality: nullIfUndefined(change.doubleDependentLocality),
|
|
35
|
+
line1: null,
|
|
36
|
+
line2: null,
|
|
37
|
+
line3: null,
|
|
38
|
+
line4: null,
|
|
39
|
+
line5: null,
|
|
40
|
+
uprn: change.uprn // required for DAL/v1
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Builds address variables for a manually entered address (without UPRN).
|
|
46
|
+
*
|
|
47
|
+
* When there is no UPRN, the DAL/v1 applies stricter validation and requires
|
|
48
|
+
* the following fields:
|
|
49
|
+
* - `line1`
|
|
50
|
+
* - `city`
|
|
51
|
+
* - `postalCode`
|
|
52
|
+
* - `country`
|
|
53
|
+
*
|
|
54
|
+
* The manually entered address fields are mapped into the DAL structure as follows:
|
|
55
|
+
*
|
|
56
|
+
* | User input field | DAL field |
|
|
57
|
+
* |------------------|-----------|
|
|
58
|
+
* | address1 | line1 |
|
|
59
|
+
* | address2 | line2 |
|
|
60
|
+
* | address3 | line3 |
|
|
61
|
+
* | county | line4 |
|
|
62
|
+
* | city | city |
|
|
63
|
+
*
|
|
64
|
+
* `line5` is not used for manual addresses and is explicitly set to `null`.
|
|
65
|
+
*
|
|
66
|
+
* Optional fields are normalized using `nullIfUndefined` so that `undefined`
|
|
67
|
+
* values are converted to `null`, ensuring consistent data sent to the DAL.
|
|
68
|
+
*
|
|
69
|
+
* @param {Object} change - The address change object containing manually entered address fields
|
|
70
|
+
* @returns {Object} Address object formatted for DAL/v1 without UPRN
|
|
71
|
+
*/
|
|
72
|
+
const buildManualAddress = (change) => {
|
|
73
|
+
return {
|
|
74
|
+
pafOrganisationName: null,
|
|
75
|
+
buildingNumberRange: null,
|
|
76
|
+
buildingName: null,
|
|
77
|
+
flatName: null,
|
|
78
|
+
street: null,
|
|
79
|
+
dependentLocality: null,
|
|
80
|
+
doubleDependentLocality: null,
|
|
81
|
+
county: null,
|
|
82
|
+
uprn: null,
|
|
83
|
+
line1: change.address1, // required for DAL/v1
|
|
84
|
+
line2: nullIfUndefined(change.address2),
|
|
85
|
+
line3: nullIfUndefined(change.address3),
|
|
86
|
+
line4: nullIfUndefined(change.county), // manual county mapped for validation
|
|
87
|
+
line5: null,
|
|
88
|
+
city: change.city, // required for DAL/v1
|
|
89
|
+
postalCode: change.postcode, // required for DAL/v1
|
|
90
|
+
country: change.country // required for DAL/v1
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Normalizes a value to null if it is undefined.
|
|
96
|
+
* @param {*} value - The value to normalize
|
|
97
|
+
* @returns {*|null} The value if defined, otherwise null
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
100
|
+
const nullIfUndefined = (value) => {
|
|
101
|
+
return value ?? null
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
buildUprnAddress,
|
|
106
|
+
buildManualAddress
|
|
107
|
+
}
|
package/src/services/services.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { addressLookupService } from './os-places/address-lookup-service.js'
|
|
2
|
+
import { buildUprnAddress, buildManualAddress } from './build-address-variables-service.js'
|
|
2
3
|
|
|
3
4
|
export const services = {
|
|
4
|
-
addressLookup: addressLookupService
|
|
5
|
+
addressLookup: addressLookupService,
|
|
6
|
+
buildUprnAddress,
|
|
7
|
+
buildManualAddress
|
|
5
8
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the GraphQL variables for the `updateBusinessPhoneNumbers` mutation.
|
|
3
|
+
*
|
|
4
|
+
* @param {string|null} businessTelephone - The new business landline number
|
|
5
|
+
* @param {string|null} businessMobile - The new business mobile number
|
|
6
|
+
* @param {string} sbi = The Single Business Identifier of the business being updated
|
|
7
|
+
* @returns {object} The mutation variables in the shape `{ input: { phone { landline, mobile }, sbi } }
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const buildUpdateBusinessPhoneNumbersVariables = (businessTelephone, businessMobile, sbi) => {
|
|
11
|
+
return {
|
|
12
|
+
input: {
|
|
13
|
+
phone: {
|
|
14
|
+
landline: businessTelephone ?? null,
|
|
15
|
+
mobile: businessMobile ?? null
|
|
16
|
+
},
|
|
17
|
+
sbi
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/utils/utils.js
CHANGED
|
@@ -2,10 +2,12 @@ import { formatFullName } from './format-full-name.js'
|
|
|
2
2
|
import { formatValidationErrors } from './format-validation-errors.js'
|
|
3
3
|
import { buildUpdateBusinessEmailVariables } from './build-update-business-email-variables.js'
|
|
4
4
|
import { buildUpdateBusinessNameVariables } from './build-update-business-name-variables.js'
|
|
5
|
+
import { buildUpdateBusinessPhoneNumbersVariables } from './build-update-business-phone-numbers-variables.js'
|
|
5
6
|
|
|
6
7
|
export const utils = {
|
|
7
8
|
formatFullName,
|
|
8
9
|
formatValidationErrors,
|
|
9
10
|
buildUpdateBusinessEmailVariables,
|
|
10
|
-
buildUpdateBusinessNameVariables
|
|
11
|
+
buildUpdateBusinessNameVariables,
|
|
12
|
+
buildUpdateBusinessPhoneNumbersVariables
|
|
11
13
|
}
|