@defra/fcp-sfd-frontend-engine 0.32.0 → 0.33.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
@@ -302,13 +302,11 @@ var constants = {
302
302
  // src/mappers/personal-business-details-mapper.js
303
303
  var mapPersonalBusinessDetails = (value) => {
304
304
  return {
305
- info: { ...mappers.customerName(value.customer.info.name) },
305
+ userName: mappers.customerName(value.customer.info.name),
306
306
  business: {
307
- info: {
308
- organisationId: value.business.organisationId ?? null,
309
- sbi: value.business.sbi ?? null,
310
- name: value.business.info.name ?? null
311
- }
307
+ organisationId: value.business.organisationId ?? null,
308
+ sbi: value.business.sbi ?? null,
309
+ name: value.business.info.name ?? null
312
310
  }
313
311
  };
314
312
  };
@@ -342,18 +340,17 @@ var mapAddress = (address = {}) => {
342
340
 
343
341
  // src/mappers/customer-name-mapper.js
344
342
  var mapCustomerName = (name = {}) => {
345
- return {
346
- userName: [
347
- name.first,
348
- name.last
349
- ].filter(Boolean).join(" ")
350
- };
343
+ return [
344
+ name.first,
345
+ name.last
346
+ ].filter(Boolean).join(" ");
351
347
  };
352
348
 
353
349
  // src/mappers/business-details-mapper.js
354
350
  var asNullable = (value) => value ?? null;
355
- var mapBusinessInfo = (business) => {
356
- var _a, _b, _c;
351
+ var mapBusinessDetails = (value) => {
352
+ var _a, _b, _c, _d, _e, _f;
353
+ const business = (value == null ? void 0 : value.business) ?? {};
357
354
  const info = business.info ?? {};
358
355
  const registrationNumbers = info.registrationNumbers ?? {};
359
356
  return {
@@ -369,24 +366,11 @@ var mapBusinessInfo = (business) => {
369
366
  charityCommission: asNullable(registrationNumbers.charityCommission)
370
367
  },
371
368
  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)
369
+ countyParishHoldingNumbers: business.countyParishHoldings ?? [],
370
+ address: mapAddress(info.address),
371
+ email: asNullable((_d = info.email) == null ? void 0 : _d.address),
372
+ landline: asNullable((_e = info.phone) == null ? void 0 : _e.landline),
373
+ mobile: asNullable((_f = info.phone) == null ? void 0 : _f.mobile)
390
374
  };
391
375
  };
392
376
 
package/dist/index.js CHANGED
@@ -261,13 +261,11 @@ var constants = {
261
261
  // src/mappers/personal-business-details-mapper.js
262
262
  var mapPersonalBusinessDetails = (value) => {
263
263
  return {
264
- info: { ...mappers.customerName(value.customer.info.name) },
264
+ userName: mappers.customerName(value.customer.info.name),
265
265
  business: {
266
- info: {
267
- organisationId: value.business.organisationId ?? null,
268
- sbi: value.business.sbi ?? null,
269
- name: value.business.info.name ?? null
270
- }
266
+ organisationId: value.business.organisationId ?? null,
267
+ sbi: value.business.sbi ?? null,
268
+ name: value.business.info.name ?? null
271
269
  }
272
270
  };
273
271
  };
@@ -301,18 +299,17 @@ var mapAddress = (address = {}) => {
301
299
 
302
300
  // src/mappers/customer-name-mapper.js
303
301
  var mapCustomerName = (name = {}) => {
304
- return {
305
- userName: [
306
- name.first,
307
- name.last
308
- ].filter(Boolean).join(" ")
309
- };
302
+ return [
303
+ name.first,
304
+ name.last
305
+ ].filter(Boolean).join(" ");
310
306
  };
311
307
 
312
308
  // src/mappers/business-details-mapper.js
313
309
  var asNullable = (value) => value ?? null;
314
- var mapBusinessInfo = (business) => {
315
- var _a, _b, _c;
310
+ var mapBusinessDetails = (value) => {
311
+ var _a, _b, _c, _d, _e, _f;
312
+ const business = (value == null ? void 0 : value.business) ?? {};
316
313
  const info = business.info ?? {};
317
314
  const registrationNumbers = info.registrationNumbers ?? {};
318
315
  return {
@@ -328,24 +325,11 @@ var mapBusinessInfo = (business) => {
328
325
  charityCommission: asNullable(registrationNumbers.charityCommission)
329
326
  },
330
327
  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)
328
+ countyParishHoldingNumbers: business.countyParishHoldings ?? [],
329
+ address: mapAddress(info.address),
330
+ email: asNullable((_d = info.email) == null ? void 0 : _d.address),
331
+ landline: asNullable((_e = info.phone) == null ? void 0 : _e.landline),
332
+ mobile: asNullable((_f = info.phone) == null ? void 0 : _f.mobile)
349
333
  };
350
334
  };
351
335
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra/fcp-sfd-frontend-engine",
3
- "version": "0.32.0",
3
+ "version": "0.33.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": {
@@ -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
  }