@defra/fcp-sfd-frontend-engine 0.32.1 → 0.34.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
@@ -232,6 +232,43 @@ var COMPANY_REGISTRATION_LEGAL_STATUS_CODES = [
232
232
  BUSINESS_LEGAL_STATUS2.unlimitedCompany.code
233
233
  ];
234
234
 
235
+ // src/constants/change-links.js
236
+ var INTERNAL_BUSINESS_CHANGE_LINKS = {
237
+ businessName: (sbi) => `/business/${sbi}/name-change`,
238
+ businessAddress: (sbi) => `/business/${sbi}/address-change`,
239
+ businessPhone: (sbi) => `/business/${sbi}/phone-numbers-change`,
240
+ businessEmail: (sbi) => `/business/${sbi}/email-change`,
241
+ businessVat: (sbi) => `/business/${sbi}/vat-registration-number-change`,
242
+ businessVatRemove: (sbi) => `/business/${sbi}/vat-registration-remove`,
243
+ businessLegalStatus: (sbi) => `/business/${sbi}/legal-status-change`,
244
+ businessLegalStatusRegistrationNumber: (sbi) => `/business/${sbi}/legal-status-enter`
245
+ };
246
+ var INTERNAL_PERSONAL_CHANGE_LINKS = {
247
+ personalName: (crn) => `/customer/${crn}/account-name-change`,
248
+ personalAddress: (crn) => `/customer/${crn}/account-address-change`,
249
+ personalPhone: (crn) => `/customer/${crn}/account-phone-numbers-change`,
250
+ personalEmail: (crn) => `/customer/${crn}/account-email-change`,
251
+ personalDateOfBirth: (crn) => `/customer/${crn}/account-date-of-birth-change`
252
+ };
253
+ var EXTERNAL_BUSINESS_CHANGE_LINKS = {
254
+ businessName: "/business-name-change",
255
+ businessAddress: "/business-address-change",
256
+ businessPhone: "/business-phone-numbers-change",
257
+ businessEmail: "/business-email-change",
258
+ businessVat: "/business-vat-registration-number-change",
259
+ businessVatRemove: "/business-vat-registration-remove",
260
+ businessLegalStatus: "/business-legal-status-change",
261
+ businessType: "/business-type-change",
262
+ businessFixNameNoPermission: "/business-fix-name-no-permission"
263
+ };
264
+ var EXTERNAL_PERSONAL_CHANGE_LINKS = {
265
+ personalName: "/account-name-change",
266
+ personalAddress: "/account-address-change",
267
+ personalPhone: "/account-phone-numbers-change",
268
+ personalEmail: "/account-email-change",
269
+ personalDateOfBirth: "/account-date-of-birth-change"
270
+ };
271
+
235
272
  // src/constants/index.js
236
273
  var constants = {
237
274
  statusCodes: {
@@ -296,19 +333,27 @@ var constants = {
296
333
  LEGAL_STATUS_CODES: BUSINESS_LEGAL_STATUS_CODES,
297
334
  CHARITY_REGISTRATION_LEGAL_STATUS_CODES,
298
335
  COMPANY_REGISTRATION_LEGAL_STATUS_CODES
336
+ },
337
+ changeLinks: {
338
+ internal: {
339
+ BUSINESS: INTERNAL_BUSINESS_CHANGE_LINKS,
340
+ PERSONAL: INTERNAL_PERSONAL_CHANGE_LINKS
341
+ },
342
+ external: {
343
+ BUSINESS: EXTERNAL_BUSINESS_CHANGE_LINKS,
344
+ PERSONAL: EXTERNAL_PERSONAL_CHANGE_LINKS
345
+ }
299
346
  }
300
347
  };
301
348
 
302
349
  // src/mappers/personal-business-details-mapper.js
303
350
  var mapPersonalBusinessDetails = (value) => {
304
351
  return {
305
- info: { ...mappers.customerName(value.customer.info.name) },
352
+ userName: mappers.customerName(value.customer.info.name),
306
353
  business: {
307
- info: {
308
- organisationId: value.business.organisationId ?? null,
309
- sbi: value.business.sbi ?? null,
310
- name: value.business.info.name ?? null
311
- }
354
+ organisationId: value.business.organisationId ?? null,
355
+ sbi: value.business.sbi ?? null,
356
+ name: value.business.info.name ?? null
312
357
  }
313
358
  };
314
359
  };
@@ -342,18 +387,17 @@ var mapAddress = (address = {}) => {
342
387
 
343
388
  // src/mappers/customer-name-mapper.js
344
389
  var mapCustomerName = (name = {}) => {
345
- return {
346
- userName: [
347
- name.first,
348
- name.last
349
- ].filter(Boolean).join(" ")
350
- };
390
+ return [
391
+ name.first,
392
+ name.last
393
+ ].filter(Boolean).join(" ");
351
394
  };
352
395
 
353
396
  // src/mappers/business-details-mapper.js
354
397
  var asNullable = (value) => value ?? null;
355
- var mapBusinessInfo = (business) => {
356
- var _a, _b, _c;
398
+ var mapBusinessDetails = (value) => {
399
+ var _a, _b, _c, _d, _e, _f;
400
+ const business = (value == null ? void 0 : value.business) ?? {};
357
401
  const info = business.info ?? {};
358
402
  const registrationNumbers = info.registrationNumbers ?? {};
359
403
  return {
@@ -369,24 +413,11 @@ var mapBusinessInfo = (business) => {
369
413
  charityCommission: asNullable(registrationNumbers.charityCommission)
370
414
  },
371
415
  type: asNullable((_c = info.type) == null ? void 0 : _c.type),
372
- countyParishHoldingNumbers: business.countyParishHoldings ?? []
373
- };
374
- };
375
- var mapBusinessContact = (businessInfo) => {
376
- var _a, _b, _c;
377
- return {
378
- email: asNullable((_a = businessInfo.email) == null ? void 0 : _a.address),
379
- landline: asNullable((_b = businessInfo.phone) == null ? void 0 : _b.landline),
380
- mobile: asNullable((_c = businessInfo.phone) == null ? void 0 : _c.mobile)
381
- };
382
- };
383
- var mapBusinessDetails = (value) => {
384
- const business = (value == null ? void 0 : value.business) ?? {};
385
- const businessInfo = business.info ?? {};
386
- return {
387
- info: mapBusinessInfo(business),
388
- address: mapAddress(businessInfo.address),
389
- contact: mapBusinessContact(businessInfo)
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)
390
421
  };
391
422
  };
392
423
 
package/dist/index.js CHANGED
@@ -191,6 +191,43 @@ var COMPANY_REGISTRATION_LEGAL_STATUS_CODES = [
191
191
  BUSINESS_LEGAL_STATUS2.unlimitedCompany.code
192
192
  ];
193
193
 
194
+ // src/constants/change-links.js
195
+ var INTERNAL_BUSINESS_CHANGE_LINKS = {
196
+ businessName: (sbi) => `/business/${sbi}/name-change`,
197
+ businessAddress: (sbi) => `/business/${sbi}/address-change`,
198
+ businessPhone: (sbi) => `/business/${sbi}/phone-numbers-change`,
199
+ businessEmail: (sbi) => `/business/${sbi}/email-change`,
200
+ businessVat: (sbi) => `/business/${sbi}/vat-registration-number-change`,
201
+ businessVatRemove: (sbi) => `/business/${sbi}/vat-registration-remove`,
202
+ businessLegalStatus: (sbi) => `/business/${sbi}/legal-status-change`,
203
+ businessLegalStatusRegistrationNumber: (sbi) => `/business/${sbi}/legal-status-enter`
204
+ };
205
+ var INTERNAL_PERSONAL_CHANGE_LINKS = {
206
+ personalName: (crn) => `/customer/${crn}/account-name-change`,
207
+ personalAddress: (crn) => `/customer/${crn}/account-address-change`,
208
+ personalPhone: (crn) => `/customer/${crn}/account-phone-numbers-change`,
209
+ personalEmail: (crn) => `/customer/${crn}/account-email-change`,
210
+ personalDateOfBirth: (crn) => `/customer/${crn}/account-date-of-birth-change`
211
+ };
212
+ var EXTERNAL_BUSINESS_CHANGE_LINKS = {
213
+ businessName: "/business-name-change",
214
+ businessAddress: "/business-address-change",
215
+ businessPhone: "/business-phone-numbers-change",
216
+ businessEmail: "/business-email-change",
217
+ businessVat: "/business-vat-registration-number-change",
218
+ businessVatRemove: "/business-vat-registration-remove",
219
+ businessLegalStatus: "/business-legal-status-change",
220
+ businessType: "/business-type-change",
221
+ businessFixNameNoPermission: "/business-fix-name-no-permission"
222
+ };
223
+ var EXTERNAL_PERSONAL_CHANGE_LINKS = {
224
+ personalName: "/account-name-change",
225
+ personalAddress: "/account-address-change",
226
+ personalPhone: "/account-phone-numbers-change",
227
+ personalEmail: "/account-email-change",
228
+ personalDateOfBirth: "/account-date-of-birth-change"
229
+ };
230
+
194
231
  // src/constants/index.js
195
232
  var constants = {
196
233
  statusCodes: {
@@ -255,19 +292,27 @@ var constants = {
255
292
  LEGAL_STATUS_CODES: BUSINESS_LEGAL_STATUS_CODES,
256
293
  CHARITY_REGISTRATION_LEGAL_STATUS_CODES,
257
294
  COMPANY_REGISTRATION_LEGAL_STATUS_CODES
295
+ },
296
+ changeLinks: {
297
+ internal: {
298
+ BUSINESS: INTERNAL_BUSINESS_CHANGE_LINKS,
299
+ PERSONAL: INTERNAL_PERSONAL_CHANGE_LINKS
300
+ },
301
+ external: {
302
+ BUSINESS: EXTERNAL_BUSINESS_CHANGE_LINKS,
303
+ PERSONAL: EXTERNAL_PERSONAL_CHANGE_LINKS
304
+ }
258
305
  }
259
306
  };
260
307
 
261
308
  // src/mappers/personal-business-details-mapper.js
262
309
  var mapPersonalBusinessDetails = (value) => {
263
310
  return {
264
- info: { ...mappers.customerName(value.customer.info.name) },
311
+ userName: mappers.customerName(value.customer.info.name),
265
312
  business: {
266
- info: {
267
- organisationId: value.business.organisationId ?? null,
268
- sbi: value.business.sbi ?? null,
269
- name: value.business.info.name ?? null
270
- }
313
+ organisationId: value.business.organisationId ?? null,
314
+ sbi: value.business.sbi ?? null,
315
+ name: value.business.info.name ?? null
271
316
  }
272
317
  };
273
318
  };
@@ -301,18 +346,17 @@ var mapAddress = (address = {}) => {
301
346
 
302
347
  // src/mappers/customer-name-mapper.js
303
348
  var mapCustomerName = (name = {}) => {
304
- return {
305
- userName: [
306
- name.first,
307
- name.last
308
- ].filter(Boolean).join(" ")
309
- };
349
+ return [
350
+ name.first,
351
+ name.last
352
+ ].filter(Boolean).join(" ");
310
353
  };
311
354
 
312
355
  // src/mappers/business-details-mapper.js
313
356
  var asNullable = (value) => value ?? null;
314
- var mapBusinessInfo = (business) => {
315
- var _a, _b, _c;
357
+ var mapBusinessDetails = (value) => {
358
+ var _a, _b, _c, _d, _e, _f;
359
+ const business = (value == null ? void 0 : value.business) ?? {};
316
360
  const info = business.info ?? {};
317
361
  const registrationNumbers = info.registrationNumbers ?? {};
318
362
  return {
@@ -328,24 +372,11 @@ var mapBusinessInfo = (business) => {
328
372
  charityCommission: asNullable(registrationNumbers.charityCommission)
329
373
  },
330
374
  type: asNullable((_c = info.type) == null ? void 0 : _c.type),
331
- countyParishHoldingNumbers: business.countyParishHoldings ?? []
332
- };
333
- };
334
- var mapBusinessContact = (businessInfo) => {
335
- var _a, _b, _c;
336
- return {
337
- email: asNullable((_a = businessInfo.email) == null ? void 0 : _a.address),
338
- landline: asNullable((_b = businessInfo.phone) == null ? void 0 : _b.landline),
339
- mobile: asNullable((_c = businessInfo.phone) == null ? void 0 : _c.mobile)
340
- };
341
- };
342
- var mapBusinessDetails = (value) => {
343
- const business = (value == null ? void 0 : value.business) ?? {};
344
- const businessInfo = business.info ?? {};
345
- return {
346
- info: mapBusinessInfo(business),
347
- address: mapAddress(businessInfo.address),
348
- contact: mapBusinessContact(businessInfo)
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)
349
380
  };
350
381
  };
351
382
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/fcp-sfd-frontend-engine",
3
- "version": "0.32.1",
3
+ "version": "0.34.0",
4
4
  "description": "Shared frontend engine used by both the internal and external frontend applications.",
5
5
  "main": "./dist/index.cjs",
6
6
  "exports": {
@@ -0,0 +1,42 @@
1
+ // The internal service reaches records by SBI/CRN search, so its paths are parameterised functions.
2
+ // The external service works from the signed-in user's own records, so its paths are static strings.
3
+ // The two sets are not interchangeable — use the one matching the consuming service.
4
+
5
+ export const INTERNAL_BUSINESS_CHANGE_LINKS = {
6
+ businessName: (sbi) => `/business/${sbi}/name-change`,
7
+ businessAddress: (sbi) => `/business/${sbi}/address-change`,
8
+ businessPhone: (sbi) => `/business/${sbi}/phone-numbers-change`,
9
+ businessEmail: (sbi) => `/business/${sbi}/email-change`,
10
+ businessVat: (sbi) => `/business/${sbi}/vat-registration-number-change`,
11
+ businessVatRemove: (sbi) => `/business/${sbi}/vat-registration-remove`,
12
+ businessLegalStatus: (sbi) => `/business/${sbi}/legal-status-change`,
13
+ businessLegalStatusRegistrationNumber: (sbi) => `/business/${sbi}/legal-status-enter`
14
+ }
15
+
16
+ export const INTERNAL_PERSONAL_CHANGE_LINKS = {
17
+ personalName: (crn) => `/customer/${crn}/account-name-change`,
18
+ personalAddress: (crn) => `/customer/${crn}/account-address-change`,
19
+ personalPhone: (crn) => `/customer/${crn}/account-phone-numbers-change`,
20
+ personalEmail: (crn) => `/customer/${crn}/account-email-change`,
21
+ personalDateOfBirth: (crn) => `/customer/${crn}/account-date-of-birth-change`
22
+ }
23
+
24
+ export const EXTERNAL_BUSINESS_CHANGE_LINKS = {
25
+ businessName: '/business-name-change',
26
+ businessAddress: '/business-address-change',
27
+ businessPhone: '/business-phone-numbers-change',
28
+ businessEmail: '/business-email-change',
29
+ businessVat: '/business-vat-registration-number-change',
30
+ businessVatRemove: '/business-vat-registration-remove',
31
+ businessLegalStatus: '/business-legal-status-change',
32
+ businessType: '/business-type-change',
33
+ businessFixNameNoPermission: '/business-fix-name-no-permission'
34
+ }
35
+
36
+ export const EXTERNAL_PERSONAL_CHANGE_LINKS = {
37
+ personalName: '/account-name-change',
38
+ personalAddress: '/account-address-change',
39
+ personalPhone: '/account-phone-numbers-change',
40
+ personalEmail: '/account-email-change',
41
+ personalDateOfBirth: '/account-date-of-birth-change'
42
+ }
@@ -69,6 +69,14 @@ import {
69
69
  COMPANY_REGISTRATION_LEGAL_STATUS_CODES
70
70
  } from './business-legal-status.js'
71
71
 
72
+ // Change links
73
+ import {
74
+ INTERNAL_BUSINESS_CHANGE_LINKS,
75
+ INTERNAL_PERSONAL_CHANGE_LINKS,
76
+ EXTERNAL_BUSINESS_CHANGE_LINKS,
77
+ EXTERNAL_PERSONAL_CHANGE_LINKS
78
+ } from './change-links.js'
79
+
72
80
  export const constants = {
73
81
  statusCodes: {
74
82
  BAD_REQUEST,
@@ -132,5 +140,15 @@ export const constants = {
132
140
  LEGAL_STATUS_CODES: BUSINESS_LEGAL_STATUS_CODES,
133
141
  CHARITY_REGISTRATION_LEGAL_STATUS_CODES,
134
142
  COMPANY_REGISTRATION_LEGAL_STATUS_CODES
143
+ },
144
+ changeLinks: {
145
+ internal: {
146
+ BUSINESS: INTERNAL_BUSINESS_CHANGE_LINKS,
147
+ PERSONAL: INTERNAL_PERSONAL_CHANGE_LINKS
148
+ },
149
+ external: {
150
+ BUSINESS: EXTERNAL_BUSINESS_CHANGE_LINKS,
151
+ PERSONAL: EXTERNAL_PERSONAL_CHANGE_LINKS
152
+ }
135
153
  }
136
154
  }
@@ -1,19 +1,20 @@
1
1
  /**
2
2
  * Takes the raw business details data from the DAL and maps it to a more usable format.
3
3
  *
4
- * Maps the core `info`, `address`, and `contact` fields.
4
+ * Maps the core business fields, `address`, and contact fields onto a single flat object.
5
5
  * Callers that need additional fields (e.g. `customer`) should extend the result.
6
6
  *
7
7
  * @param {Object} value - The raw data from the DAL
8
8
  *
9
- * @returns {Object} Mapped business details with `info`, `address`, and `contact`
9
+ * @returns {Object} Mapped business details
10
10
  */
11
11
 
12
12
  import { mapAddress } from './address-mapper.js'
13
13
 
14
14
  const asNullable = (value) => value ?? null
15
15
 
16
- const mapBusinessInfo = (business) => {
16
+ export const mapBusinessDetails = (value) => {
17
+ const business = value?.business ?? {}
17
18
  const info = business.info ?? {}
18
19
  const registrationNumbers = info.registrationNumbers ?? {}
19
20
 
@@ -30,25 +31,10 @@ const mapBusinessInfo = (business) => {
30
31
  charityCommission: asNullable(registrationNumbers.charityCommission)
31
32
  },
32
33
  type: asNullable(info.type?.type),
33
- countyParishHoldingNumbers: business.countyParishHoldings ?? []
34
- }
35
- }
36
-
37
- const mapBusinessContact = (businessInfo) => {
38
- return {
39
- email: asNullable(businessInfo.email?.address),
40
- landline: asNullable(businessInfo.phone?.landline),
41
- mobile: asNullable(businessInfo.phone?.mobile)
42
- }
43
- }
44
-
45
- export const mapBusinessDetails = (value) => {
46
- const business = value?.business ?? {}
47
- const businessInfo = business.info ?? {}
48
-
49
- return {
50
- info: mapBusinessInfo(business),
51
- address: mapAddress(businessInfo.address),
52
- contact: mapBusinessContact(businessInfo)
34
+ countyParishHoldingNumbers: business.countyParishHoldings ?? [],
35
+ address: mapAddress(info.address),
36
+ email: asNullable(info.email?.address),
37
+ landline: asNullable(info.phone?.landline),
38
+ mobile: asNullable(info.phone?.mobile)
53
39
  }
54
40
  }
@@ -3,14 +3,12 @@
3
3
  *
4
4
  * @param {Object} value - The data from the DAL
5
5
  *
6
- * @returns {Object} Formatted customer name data
6
+ * @returns {string} Formatted customer name
7
7
  */
8
8
 
9
9
  export const mapCustomerName = (name = {}) => {
10
- return {
11
- userName: [
12
- name.first,
13
- name.last
14
- ].filter(Boolean).join(' ')
15
- }
10
+ return [
11
+ name.first,
12
+ name.last
13
+ ].filter(Boolean).join(' ')
16
14
  }
@@ -10,13 +10,11 @@ import { mappers } from './mappers'
10
10
 
11
11
  export const mapPersonalBusinessDetails = (value) => {
12
12
  return {
13
- info: { ...mappers.customerName(value.customer.info.name) },
13
+ userName: mappers.customerName(value.customer.info.name),
14
14
  business: {
15
- info: {
16
- organisationId: value.business.organisationId ?? null,
17
- sbi: value.business.sbi ?? null,
18
- name: value.business.info.name ?? null
19
- }
15
+ organisationId: value.business.organisationId ?? null,
16
+ sbi: value.business.sbi ?? null,
17
+ name: value.business.info.name ?? null
20
18
  }
21
19
  }
22
20
  }