@tillhub/schemas 6.181.0 → 6.183.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/CHANGELOG.md +15 -0
- package/lib/common/webhooks.js +53 -0
- package/lib/v0/stocks_book/base.js +2 -2
- package/lib/v0/stocks_book/create.js +35 -18
- package/lib/v1/transactions/{create.request.js → create.js} +1 -1
- package/lib/v1/transactions/index.js +4 -3
- package/lib/v1/transactions/legacy/{create.request.js → create.js} +9 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
|
+
# [6.183.0](https://github.com/tillhub/schemas/compare/v6.182.0...v6.183.0) (2022-12-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **stocks-book:** add transaction event schema #UNTIL-5820 ([b458c35](https://github.com/tillhub/schemas/commit/b458c35)), closes [#UNTIL-5820](https://github.com/tillhub/schemas/issues/UNTIL-5820)
|
|
7
|
+
* **stocks-book:** align schema with requirements v4 #UNTIL-5820 ([eae9837](https://github.com/tillhub/schemas/commit/eae9837)), closes [#UNTIL-5820](https://github.com/tillhub/schemas/issues/UNTIL-5820)
|
|
8
|
+
|
|
9
|
+
# [6.182.0](https://github.com/tillhub/schemas/compare/v6.181.0...v6.182.0) (2022-12-13)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* **stocks-book:** align schema with requirements v3 #UNTIL-5820 ([9a828b3](https://github.com/tillhub/schemas/commit/9a828b3)), closes [#UNTIL-5820](https://github.com/tillhub/schemas/issues/UNTIL-5820)
|
|
15
|
+
|
|
1
16
|
# [6.181.0](https://github.com/tillhub/schemas/compare/v6.180.0...v6.181.0) (2022-12-12)
|
|
2
17
|
|
|
3
18
|
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module.exports.getEvent = function getEvent (payload, {
|
|
2
|
+
eventEntityExample = 'ice-cream',
|
|
3
|
+
eventTypeExample = 'create',
|
|
4
|
+
eventVersionExample = 0
|
|
5
|
+
} = {}) {
|
|
6
|
+
return {
|
|
7
|
+
description: 'The webhook data set',
|
|
8
|
+
type: 'object',
|
|
9
|
+
additionalProperties: false,
|
|
10
|
+
properties: {
|
|
11
|
+
webhookId: {
|
|
12
|
+
description: 'The webhook UUID',
|
|
13
|
+
example: 'ff30cfdf-5167-4f72-b4fc-c1d72db3c07e',
|
|
14
|
+
type: 'string',
|
|
15
|
+
format: 'uuid'
|
|
16
|
+
},
|
|
17
|
+
eventId: {
|
|
18
|
+
description: 'The event UUID',
|
|
19
|
+
example: 'c6fe918a-7bdc-4ccd-af36-95c03853233d',
|
|
20
|
+
type: 'string',
|
|
21
|
+
format: 'uuid'
|
|
22
|
+
},
|
|
23
|
+
eventEntity: {
|
|
24
|
+
description: 'The entity name the event refers to',
|
|
25
|
+
example: eventEntityExample,
|
|
26
|
+
type: 'string'
|
|
27
|
+
},
|
|
28
|
+
eventType: {
|
|
29
|
+
description: 'The event type (e.g. create, update, delete)',
|
|
30
|
+
example: eventTypeExample,
|
|
31
|
+
type: 'string'
|
|
32
|
+
},
|
|
33
|
+
eventVersion: {
|
|
34
|
+
description: 'The event payload version',
|
|
35
|
+
example: eventVersionExample,
|
|
36
|
+
type: 'number'
|
|
37
|
+
},
|
|
38
|
+
entityInstanceId: {
|
|
39
|
+
description: 'The entity instance UUID',
|
|
40
|
+
example: '10b06f38-031d-4e0c-8706-0474c8c5b61c',
|
|
41
|
+
type: 'string',
|
|
42
|
+
format: 'uuid'
|
|
43
|
+
},
|
|
44
|
+
timestamp: {
|
|
45
|
+
description: 'The date and time event was received by webhooks service',
|
|
46
|
+
example: new Date().toISOString(),
|
|
47
|
+
type: 'string',
|
|
48
|
+
format: 'date-time'
|
|
49
|
+
},
|
|
50
|
+
payload
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -91,7 +91,7 @@ const simple = {
|
|
|
91
91
|
minLength: 1
|
|
92
92
|
}
|
|
93
93
|
}),
|
|
94
|
-
type:
|
|
94
|
+
type: {
|
|
95
95
|
description: 'The type of stock book',
|
|
96
96
|
type: 'string',
|
|
97
97
|
enum: [
|
|
@@ -107,7 +107,7 @@ const simple = {
|
|
|
107
107
|
'delivery_note_refund',
|
|
108
108
|
'delivery_note_cancellation'
|
|
109
109
|
]
|
|
110
|
-
}
|
|
110
|
+
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
module.exports.simple = simple
|
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
const pick = require('just-pick')
|
|
2
2
|
const { oneOf } = require('../../helpers/payload-or-null')
|
|
3
3
|
const baseObject = require('../../common/base')
|
|
4
|
+
const { getEvent } = require('../../common/webhooks')
|
|
4
5
|
const baseProduct = require('../../v1/products/base').response
|
|
5
6
|
const baseBranch = require('../../v0/branches/base')
|
|
6
7
|
const baseStockBook = require('./base').simple
|
|
7
8
|
|
|
9
|
+
/**
|
|
10
|
+
* We transform all possible types into more generic ones:
|
|
11
|
+
* 'transfer': 'add', 'deduct', 'goods_in', 'goods_out', 'relocation'
|
|
12
|
+
* 'sale': 'sale', 'cancellation', 'refund'
|
|
13
|
+
* 'delivery_note': 'delivery_note', 'delivery_note_cancellation', 'delivery_note_refund"
|
|
14
|
+
*/
|
|
15
|
+
const eventTypeEnum = ['transfer', 'sale', 'delivery_note']
|
|
16
|
+
|
|
8
17
|
const eventBaseData = pick({
|
|
9
18
|
...baseObject({ entityName: 'stock book' }),
|
|
10
|
-
...baseStockBook
|
|
11
|
-
|
|
19
|
+
...baseStockBook,
|
|
20
|
+
type: {
|
|
21
|
+
...baseStockBook.type,
|
|
22
|
+
enum: eventTypeEnum
|
|
23
|
+
}
|
|
24
|
+
}, ['id', 'created_at', 'qty_change', 'type'])
|
|
12
25
|
|
|
13
26
|
const eventOverrideData = {
|
|
14
27
|
product: {
|
|
@@ -19,10 +32,10 @@ const eventOverrideData = {
|
|
|
19
32
|
...baseObject(),
|
|
20
33
|
...baseProduct
|
|
21
34
|
}, [
|
|
22
|
-
'id',
|
|
23
35
|
'name',
|
|
24
36
|
'client_id',
|
|
25
|
-
'custom_id'
|
|
37
|
+
'custom_id',
|
|
38
|
+
'custom_properties'
|
|
26
39
|
])
|
|
27
40
|
},
|
|
28
41
|
location: {
|
|
@@ -33,7 +46,6 @@ const eventOverrideData = {
|
|
|
33
46
|
...baseObject(),
|
|
34
47
|
...baseBranch
|
|
35
48
|
}, [
|
|
36
|
-
'id',
|
|
37
49
|
'name',
|
|
38
50
|
'custom_id',
|
|
39
51
|
'branch_number',
|
|
@@ -42,7 +54,8 @@ const eventOverrideData = {
|
|
|
42
54
|
},
|
|
43
55
|
reason: oneOf({
|
|
44
56
|
description: 'The reason of stock book',
|
|
45
|
-
type: 'string'
|
|
57
|
+
type: 'string',
|
|
58
|
+
example: 'Not arbitrary reason'
|
|
46
59
|
})
|
|
47
60
|
}
|
|
48
61
|
|
|
@@ -50,17 +63,21 @@ module.exports = {
|
|
|
50
63
|
event: {
|
|
51
64
|
$id: 'https://schemas.tillhub.com/v0/stocks-book.create.event.schema.json',
|
|
52
65
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
...getEvent({
|
|
67
|
+
type: 'object',
|
|
68
|
+
additionalProperties: false,
|
|
69
|
+
required: [
|
|
70
|
+
'id',
|
|
71
|
+
'created_at',
|
|
72
|
+
'qty_change',
|
|
73
|
+
'type',
|
|
74
|
+
'product',
|
|
75
|
+
'location'
|
|
76
|
+
],
|
|
77
|
+
properties: {
|
|
78
|
+
...eventBaseData,
|
|
79
|
+
...eventOverrideData
|
|
80
|
+
}
|
|
81
|
+
}, { eventEntityExample: 'stocks-book' })
|
|
65
82
|
}
|
|
66
83
|
}
|
|
@@ -3,7 +3,7 @@ const itemsCreate = require('./components/items/create.request')
|
|
|
3
3
|
const paymentsCreate = require('./components/payments/create.request')
|
|
4
4
|
const statusCreate = require('../statuses/create.request')
|
|
5
5
|
|
|
6
|
-
module.exports = {
|
|
6
|
+
module.exports.request = {
|
|
7
7
|
$id: 'https://schemas.tillhub.com/v1/transactions.create.request.schema.json',
|
|
8
8
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
9
9
|
type: 'object',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const commonResponse = require('../../common/response')
|
|
2
2
|
|
|
3
3
|
module.exports.create = {
|
|
4
|
-
request: require('./create.request
|
|
4
|
+
request: require('./create').request,
|
|
5
5
|
response: {
|
|
6
6
|
$id: 'https://schemas.tillhub.com/v1/transactions.post.response.schema.json',
|
|
7
7
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
@@ -28,12 +28,13 @@ module.exports.get = {
|
|
|
28
28
|
|
|
29
29
|
module.exports.legacy = {
|
|
30
30
|
create: {
|
|
31
|
-
request: require('./legacy/create.request
|
|
31
|
+
request: require('./legacy/create').request,
|
|
32
32
|
response: {
|
|
33
33
|
$id: 'https://schemas.tillhub.com/v1/transactions.legacy.post.response.schema.json',
|
|
34
34
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
35
35
|
...commonResponse({ resultItems: require('./legacy/response') })
|
|
36
|
-
}
|
|
36
|
+
},
|
|
37
|
+
event: require('./legacy/create').event
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
const { getEvent } = require('../../../common/webhooks')
|
|
1
2
|
const statusCreate = require('../../statuses/create.request')
|
|
2
3
|
const base = require('./base')
|
|
4
|
+
const response = require('./response')
|
|
3
5
|
const itemsCreate = require('./items/create.request')
|
|
4
6
|
const paymentsCreate = require('./payments/create.request')
|
|
5
7
|
|
|
6
|
-
module.exports = {
|
|
8
|
+
module.exports.request = {
|
|
7
9
|
$id: 'https://schemas.tillhub.com/v1/transactions.legacy.create.request.schema.json',
|
|
8
10
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
9
11
|
type: 'object',
|
|
@@ -34,3 +36,9 @@ module.exports = {
|
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
}
|
|
39
|
+
|
|
40
|
+
module.exports.event = {
|
|
41
|
+
$id: 'https://schemas.tillhub.com/v1/transactions.legacy.create.event.schema.json',
|
|
42
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
43
|
+
...getEvent(response, { eventEntityExample: 'transaction' })
|
|
44
|
+
}
|