@defra-fish/sales-api-service 1.55.0 → 1.56.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/sales-api-service",
3
- "version": "1.55.0",
3
+ "version": "1.56.0",
4
4
  "description": "Rod Licensing Sales API",
5
5
  "type": "module",
6
6
  "engines": {
@@ -35,9 +35,9 @@
35
35
  "test": "echo \"Error: run tests from root\" && exit 1"
36
36
  },
37
37
  "dependencies": {
38
- "@defra-fish/business-rules-lib": "1.55.0",
39
- "@defra-fish/connectors-lib": "1.55.0",
40
- "@defra-fish/dynamics-lib": "1.55.0",
38
+ "@defra-fish/business-rules-lib": "1.56.0",
39
+ "@defra-fish/connectors-lib": "1.56.0",
40
+ "@defra-fish/dynamics-lib": "1.56.0",
41
41
  "@hapi/boom": "^9.1.2",
42
42
  "@hapi/hapi": "^20.1.3",
43
43
  "@hapi/inert": "^6.0.3",
@@ -52,5 +52,5 @@
52
52
  "moment-timezone": "^0.5.34",
53
53
  "uuid": "^8.3.2"
54
54
  },
55
- "gitHead": "3405322b81a2016ba22e530de8d096a49be0bea4"
55
+ "gitHead": "4edcdd349b077ad0bdb3e7b4029df3aba7c04b49"
56
56
  }
@@ -71,7 +71,7 @@ describe('createTransactionSchema', () => {
71
71
  await expect(createTransactionSchema.validateAsync(mockPayload)).rejects.toThrow('"permissions[0].isLicenceForYou" must be a boolean')
72
72
  })
73
73
 
74
- it('validates successfully when a uuid v4 transaction id is supplied', async () => {
74
+ it('validates successfully when a uuid v4 transactionId is supplied', async () => {
75
75
  const mockPayload = mockTransactionPayload()
76
76
  mockPayload.transactionId = '25fa0126-55da-4309-9bce-9957990d141e'
77
77
  await expect(createTransactionSchema.validateAsync(mockPayload)).resolves.not.toThrow()
@@ -90,11 +90,34 @@ describe('createTransactionSchema', () => {
90
90
  ['uuid6 string', 'a3bb189e-8bf9-3888-9912-ace4e6543002'],
91
91
  ['uuid7 string', '01927705-ffac-77b5-89af-c97451b1bbe2'],
92
92
  ['numeric', 4567]
93
- ])('fails validation when provided with a %s', async (_d, transactionId) => {
93
+ ])('fails validation when provided with a %s for transactionId', async (_d, transactionId) => {
94
94
  const mockPayload = mockTransactionPayload()
95
95
  mockPayload.transactionId = transactionId
96
96
  await expect(createTransactionSchema.validateAsync(mockPayload)).rejects.toThrow()
97
97
  })
98
+
99
+ it('validates successfully when an agreementId is supplied', async () => {
100
+ const mockPayload = mockTransactionPayload()
101
+ mockPayload.agreementId = 't3jl08v2nqqmujrnhs09pmhtjx'
102
+ await expect(createTransactionSchema.validateAsync(mockPayload)).resolves.not.toThrow()
103
+ })
104
+
105
+ it('validates successfully when agreementId is omitted', async () => {
106
+ const mockPayload = mockTransactionPayload()
107
+ await expect(createTransactionSchema.validateAsync(mockPayload)).resolves.not.toThrow()
108
+ })
109
+
110
+ it.each([
111
+ ['too short string', 'foo'],
112
+ ['too long string', 'foobarbazfoobarbazfoobarbaz'],
113
+ ['string containing invalid characters', '!3j@08v2nqqmujrnhs09_mhtjx'],
114
+ ['null', null],
115
+ ['numeric', 4567]
116
+ ])('fails validation when provided with a %s for agreementId', async (_d, agreementId) => {
117
+ const mockPayload = mockTransactionPayload()
118
+ mockPayload.agreementId = agreementId
119
+ await expect(createTransactionSchema.validateAsync(mockPayload)).rejects.toThrow()
120
+ })
98
121
  })
99
122
 
100
123
  describe('createTransactionResponseSchema', () => {
@@ -7,6 +7,8 @@ import { MAX_PERMISSIONS_PER_TRANSACTION, POCL_TRANSACTION_SOURCES } from '@defr
7
7
 
8
8
  import { v4 as uuidv4 } from 'uuid'
9
9
 
10
+ const AGREEMENT_ID_LENGTH = 26
11
+
10
12
  /**
11
13
  * Maximum number of items that can be created in a batch - limited by DynamoDB max batch size
12
14
  * @type {number}
@@ -33,7 +35,8 @@ const createTransactionRequestSchemaContent = {
33
35
  }),
34
36
  createdBy: Joi.string().optional(),
35
37
  journalId: Joi.string().optional(),
36
- transactionId: Joi.string().guid({ version: 'uuidv4' })
38
+ transactionId: Joi.string().guid({ version: 'uuidv4' }).optional(),
39
+ agreementId: Joi.string().alphanum().length(AGREEMENT_ID_LENGTH).optional()
37
40
  }
38
41
 
39
42
  /**