@defra-fish/dynamics-lib 1.35.0-rc.9 → 1.35.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@defra-fish/dynamics-lib",
3
- "version": "1.35.0-rc.9",
3
+ "version": "1.35.0",
4
4
  "description": "Framework to support integration with dynamics",
5
5
  "type": "module",
6
6
  "engines": {
@@ -43,5 +43,5 @@
43
43
  "simple-oauth2": "^4.3.0",
44
44
  "uuid": "^8.3.2"
45
45
  },
46
- "gitHead": "ab23a9e292bee3d149bb7f138750c4a55ff10ff1"
46
+ "gitHead": "be7f472adf337fc2e5b16431f2767defcab16d92"
47
47
  }
@@ -11,6 +11,7 @@ Object {
11
11
  "id": 910400195,
12
12
  "label": "England",
13
13
  },
14
+ "countryUnvalidated": "GB-ENG",
14
15
  "dataSource": Object {
15
16
  "description": "Post Office Sales",
16
17
  "id": 910400000,
@@ -28,14 +29,13 @@ Object {
28
29
  "label": "Cash",
29
30
  },
30
31
  "mobilePhone": "07722 123456",
31
- "newPaymentSource": Object {
32
+ "organisation": "Fishy Endeavours",
33
+ "paymentSource": Object {
32
34
  "description": "Worldpay",
33
35
  "id": 910400003,
34
36
  "label": "Worldpay",
35
37
  },
36
- "newStartDate": "2021-06-15",
37
- "organisation": "Fishy Endeavours",
38
- "paymentSource": "Post Office Sales",
38
+ "paymentSourceUnvalidated": "Post Office Sales",
39
39
  "permitId": "test-permit-id",
40
40
  "postalFulfilment": true,
41
41
  "postcode": "BS9 1HJ",
@@ -57,6 +57,7 @@ Object {
57
57
  "premises": "14 Howecroft Court",
58
58
  "serialNumber": "14345-48457J",
59
59
  "startDate": "2021-06-15",
60
+ "startDateUnvalidated": "2021-06-15",
60
61
  "stateCode": 1,
61
62
  "status": Object {
62
63
  "description": "Needs Review",
@@ -76,6 +77,7 @@ Object {
76
77
  "defra_birthdate": "1989-07-01",
77
78
  "defra_channelid": "948594",
78
79
  "defra_concessions": "[{\\"type\\":\\"Blue Badge\\",\\"referenceNumber\\":123456789}]",
80
+ "defra_country": "GB-ENG",
79
81
  "defra_countrylist": 910400195,
80
82
  "defra_datasource": 910400000,
81
83
  "defra_emailaddress": "daniel-ricc@example.couk",
@@ -7,9 +7,8 @@ describe('pocl staging exception entity', () => {
7
7
  optionSetData = await retrieveGlobalOptionSets().cached()
8
8
  })
9
9
  describe('maps from dynamics', () => {
10
- let exception
11
- beforeEach(() => {
12
- exception = PoclValidationError.fromResponse(
10
+ const getPOCLValidationError = () =>
11
+ PoclValidationError.fromResponse(
13
12
  {
14
13
  '@odata.etag': 'W/"56351087"',
15
14
  defra_poclvalidationerrorid: '91f15d18-0aa4-ea11-a812-000d3a64905b',
@@ -21,6 +20,7 @@ describe('pocl staging exception entity', () => {
21
20
  defra_locality: 'Stoke Bishop',
22
21
  defra_town: 'Bristol',
23
22
  defra_postcode: 'BS9 1HJ',
23
+ defra_country: 'GB-ENG',
24
24
  defra_countrylist: 910400195,
25
25
  defra_birthdate: '1989-07-01',
26
26
  defra_emailaddress: 'daniel-ricc@example.couk',
@@ -48,14 +48,13 @@ describe('pocl staging exception entity', () => {
48
48
  },
49
49
  optionSetData
50
50
  )
51
- })
52
51
 
53
52
  it('returns a PoclValidationError instance', () => {
54
- expect(exception).toBeInstanceOf(PoclValidationError)
53
+ expect(getPOCLValidationError()).toBeInstanceOf(PoclValidationError)
55
54
  })
56
55
 
57
56
  it('has the expected data', () => {
58
- expect(exception).toMatchSnapshot()
57
+ expect(getPOCLValidationError()).toMatchSnapshot()
59
58
  })
60
59
 
61
60
  it('has the expected fields', () => {
@@ -68,6 +67,7 @@ describe('pocl staging exception entity', () => {
68
67
  locality: 'Stoke Bishop',
69
68
  town: 'Bristol',
70
69
  postcode: 'BS9 1HJ',
70
+ countryUnvalidated: 'GB-ENG',
71
71
  country: expect.objectContaining({ id: 910400195, label: 'England', description: 'GB-ENG' }),
72
72
  birthDate: '1989-07-01',
73
73
  email: 'daniel-ricc@example.couk',
@@ -81,14 +81,14 @@ describe('pocl staging exception entity', () => {
81
81
  preferredMethodOfReminder: expect.objectContaining({ id: 910400002, label: 'Text', description: 'Text' }),
82
82
  postalFulfilment: true,
83
83
  concessions: '[{"type":"Blue Badge","referenceNumber":123456789}]',
84
+ startDateUnvalidated: '2021-06-15',
84
85
  startDate: '2021-06-15',
85
- newStartDate: '2021-06-15',
86
86
  serialNumber: '14345-48457J',
87
87
  permitId: 'test-permit-id',
88
88
  transactionDate: '2020-01-01T14:00:00Z',
89
89
  amount: 30,
90
- paymentSource: 'Post Office Sales',
91
- newPaymentSource: {
90
+ paymentSourceUnvalidated: 'Post Office Sales',
91
+ paymentSource: {
92
92
  description: 'Worldpay',
93
93
  id: 910400003,
94
94
  label: 'Worldpay'
@@ -101,8 +101,7 @@ describe('pocl staging exception entity', () => {
101
101
  stateCode: 1,
102
102
  errorMessage: '"permissions[0].licensee.email" must be a valid email'
103
103
  }
104
-
105
- expect(exception).toMatchObject(expect.objectContaining({ etag: 'W/"56351087"', ...expectedFields }))
104
+ expect(getPOCLValidationError()).toMatchObject(expect.objectContaining({ etag: 'W/"56351087"', ...expectedFields }))
106
105
  })
107
106
  })
108
107
 
@@ -116,6 +115,7 @@ describe('pocl staging exception entity', () => {
116
115
  validationError.locality = 'Stoke Bishop'
117
116
  validationError.town = 'Bristol'
118
117
  validationError.postcode = 'BS9 1HJ'
118
+ validationError.countryUnvalidated = 'GB-ENG'
119
119
  validationError.country = optionSetData.defra_country.options['910400195']
120
120
  validationError.birthDate = '1989-07-01'
121
121
  validationError.email = 'daniel-ricc@example.couk'
@@ -125,14 +125,14 @@ describe('pocl staging exception entity', () => {
125
125
  validationError.preferredMethodOfReminder = optionSetData.defra_preferredcontactmethod.options['910400002']
126
126
  validationError.postalFulfilment = true
127
127
  validationError.concessions = '[{"type":"Blue Badge","referenceNumber":123456789}]'
128
+ validationError.startDateUnvalidated = '2021-06-15'
128
129
  validationError.startDate = '2021-06-15'
129
- validationError.newStartDate = '2021-06-15'
130
130
  validationError.serialNumber = '14345-48457J'
131
131
  validationError.permitId = 'test-permit-id'
132
132
  validationError.transactionDate = '2020-01-01T14:00:00Z'
133
133
  validationError.amount = 30
134
- validationError.paymentSource = 'Post Office Sales'
135
- validationError.newPaymentSource = optionSetData.defra_financialtransactionsource.options['910400003']
134
+ validationError.paymentSourceUnvalidated = 'Post Office Sales'
135
+ validationError.paymentSource = optionSetData.defra_financialtransactionsource.options['910400003']
136
136
  validationError.channelId = '948594'
137
137
  validationError.methodOfPayment = optionSetData.defra_paymenttype.options['910400001']
138
138
  validationError.status = optionSetData.defra_poclvalidationerrorstatus.options['910400000']
@@ -195,9 +195,7 @@ export class BaseEntity {
195
195
  if (type === 'date') {
196
196
  value = moment(value).format('YYYY-MM-DD')
197
197
  } else if (type === 'datetime') {
198
- value = moment(value)
199
- .utc()
200
- .format('YYYY-MM-DDTHH:mm:ss[Z]')
198
+ value = moment(value).utc().format('YYYY-MM-DDTHH:mm:ss[Z]')
201
199
  } else if (type === 'optionset') {
202
200
  value = value.id
203
201
  }
@@ -375,30 +373,20 @@ export class BaseEntity {
375
373
  */
376
374
  const metadataSchema = Joi.object({
377
375
  // Local entity name
378
- localName: Joi.string()
379
- .min(1)
380
- .required(),
376
+ localName: Joi.string().min(1).required(),
381
377
  // Dynamics entity collection name
382
- dynamicsCollection: Joi.string()
383
- .min(1)
384
- .required(),
378
+ dynamicsCollection: Joi.string().min(1).required(),
385
379
  // Default filter to apply
386
380
  defaultFilter: Joi.string(),
387
381
  // Mapping definition used by the mapping functions
388
382
  mappings: Joi.object().pattern(
389
383
  Joi.string(),
390
384
  Joi.object({
391
- field: Joi.string()
392
- .min(1)
393
- .required(),
394
- type: Joi.string()
395
- .valid('string', 'integer', 'decimal', 'boolean', 'date', 'datetime', 'optionset')
396
- .required(),
385
+ field: Joi.string().min(1).required(),
386
+ type: Joi.string().valid('string', 'integer', 'decimal', 'boolean', 'date', 'datetime', 'optionset').required(),
397
387
  ref: Joi.when('type', {
398
388
  is: 'optionset',
399
- then: Joi.string()
400
- .min(1)
401
- .required(),
389
+ then: Joi.string().min(1).required(),
402
390
  otherwise: Joi.forbidden()
403
391
  })
404
392
  })
@@ -406,9 +394,7 @@ const metadataSchema = Joi.object({
406
394
  relationships: Joi.object().pattern(
407
395
  Joi.string(),
408
396
  Joi.object({
409
- property: Joi.string()
410
- .min(1)
411
- .required(),
397
+ property: Joi.string().min(1).required(),
412
398
  entity: Joi.function()
413
399
  .class()
414
400
  .custom(value => {
@@ -420,9 +406,7 @@ const metadataSchema = Joi.object({
420
406
  parent: Joi.boolean()
421
407
  })
422
408
  ),
423
- alternateKey: Joi.string()
424
- .min(1)
425
- .optional()
409
+ alternateKey: Joi.string().min(1).optional()
426
410
  }).required()
427
411
 
428
412
  /**
@@ -15,6 +15,7 @@ export class PoclValidationError extends BaseEntity {
15
15
  firstName: { field: 'defra_firstname', type: 'string' },
16
16
  lastName: { field: 'defra_name', type: 'string' },
17
17
  birthDate: { field: 'defra_birthdate', type: 'string' },
18
+ countryUnvalidated: { field: 'defra_country', type: 'string' },
18
19
  country: { field: 'defra_countrylist', type: 'optionset', ref: 'defra_country' },
19
20
  postcode: { field: 'defra_postcode', type: 'string' },
20
21
  town: { field: 'defra_town', type: 'string' },
@@ -33,14 +34,14 @@ export class PoclValidationError extends BaseEntity {
33
34
  },
34
35
  postalFulfilment: { field: 'defra_postalfulfilment', type: 'boolean' },
35
36
  concessions: { field: 'defra_concessions', type: 'string' },
36
- startDate: { field: 'defra_startdate', type: 'string' },
37
- newStartDate: { field: 'defra_newstartdate', type: 'string' },
37
+ startDateUnvalidated: { field: 'defra_startdate', type: 'string' },
38
+ startDate: { field: 'defra_newstartdate', type: 'string' },
38
39
  serialNumber: { field: 'defra_serialnumber', type: 'string' },
39
40
  permitId: { field: 'defra_permitid', type: 'string' },
40
41
  transactionDate: { field: 'defra_transactiondate', type: 'string' },
41
42
  amount: { field: 'defra_amount', type: 'decimal' },
42
- paymentSource: { field: 'defra_paymentsource', type: 'string' },
43
- newPaymentSource: { field: 'defra_newpaymentsource', type: 'optionset', ref: 'defra_financialtransactionsource' },
43
+ paymentSourceUnvalidated: { field: 'defra_paymentsource', type: 'string' },
44
+ paymentSource: { field: 'defra_newpaymentsource', type: 'optionset', ref: 'defra_financialtransactionsource' },
44
45
  channelId: { field: 'defra_channelid', type: 'string' },
45
46
  methodOfPayment: { field: 'defra_methodofpayment', type: 'optionset', ref: 'defra_paymenttype' },
46
47
  status: { field: 'defra_status', type: 'optionset', ref: 'defra_poclvalidationerrorstatus' },
@@ -99,6 +100,14 @@ export class PoclValidationError extends BaseEntity {
99
100
  * The country in the licensee address associated with this pocl record
100
101
  * @type {string}
101
102
  */
103
+ get countryUnvalidated () {
104
+ return super._getState('countryUnvalidated')
105
+ }
106
+
107
+ set countryUnvalidated (countryUnvalidated) {
108
+ super._setState('countryUnvalidated', countryUnvalidated)
109
+ }
110
+
102
111
  get country () {
103
112
  return super._getState('country')
104
113
  }
@@ -267,24 +276,24 @@ export class PoclValidationError extends BaseEntity {
267
276
  * The licence start date associated with this pocl record
268
277
  * @type {string}
269
278
  */
270
- get startDate () {
271
- return super._getState('startDate')
279
+ get startDateUnvalidated () {
280
+ return super._getState('startDateUnvalidated')
272
281
  }
273
282
 
274
- set startDate (startDate) {
275
- super._setState('startDate', startDate)
283
+ set startDateUnvalidated (startDateUnvalidated) {
284
+ super._setState('startDateUnvalidated', startDateUnvalidated)
276
285
  }
277
286
 
278
287
  /**
279
288
  * The licence new start date associated with this pocl record
280
289
  * @type {string}
281
290
  */
282
- get newStartDate () {
283
- return super._getState('newStartDate')
291
+ get startDate () {
292
+ return super._getState('startDate')
284
293
  }
285
294
 
286
- set newStartDate (newStartDate) {
287
- super._setState('newStartDate', newStartDate)
295
+ set startDate (startDate) {
296
+ super._setState('startDate', startDate)
288
297
  }
289
298
 
290
299
  /**
@@ -339,24 +348,24 @@ export class PoclValidationError extends BaseEntity {
339
348
  * The payment source associated with this pocl record
340
349
  * @type {GlobalOptionSetDefinition}
341
350
  */
342
- get newPaymentSource () {
343
- return super._getState('newPaymentSource')
351
+ get paymentSource () {
352
+ return super._getState('paymentSource')
344
353
  }
345
354
 
346
- set newPaymentSource (newPaymentSource) {
347
- super._setState('newPaymentSource', newPaymentSource)
355
+ set paymentSource (paymentSource) {
356
+ super._setState('paymentSource', paymentSource)
348
357
  }
349
358
 
350
359
  /**
351
360
  * The new payment source associated with this pocl record
352
361
  * @type {string}
353
362
  */
354
- get paymentSource () {
355
- return super._getState('paymentSource')
363
+ get paymentSourceUnvalidated () {
364
+ return super._getState('paymentSourceUnvalidated')
356
365
  }
357
366
 
358
- set paymentSource (paymentSource) {
359
- super._setState('paymentSource', paymentSource)
367
+ set paymentSourceUnvalidated (paymentSourceUnvalidated) {
368
+ super._setState('paymentSourceUnvalidated', paymentSourceUnvalidated)
360
369
  }
361
370
 
362
371
  /**