@tillhub/schemas 6.180.0 → 6.182.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 +14 -0
- package/lib/common/base.js +4 -3
- package/lib/common/wenhooks.js +49 -0
- package/lib/v0/stocks_book/create.js +31 -18
- package/lib/v0/stocks_book/read.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [6.182.0](https://github.com/tillhub/schemas/compare/v6.181.0...v6.182.0) (2022-12-13)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **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)
|
|
7
|
+
|
|
8
|
+
# [6.181.0](https://github.com/tillhub/schemas/compare/v6.180.0...v6.181.0) (2022-12-12)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **stocks-book:** align schema with requirements v1 #UNTIL-5820 ([c606cc8](https://github.com/tillhub/schemas/commit/c606cc8)), closes [#UNTIL-5820](https://github.com/tillhub/schemas/issues/UNTIL-5820)
|
|
14
|
+
|
|
1
15
|
# [6.180.0](https://github.com/tillhub/schemas/compare/v6.179.0...v6.180.0) (2022-12-12)
|
|
2
16
|
|
|
3
17
|
|
package/lib/common/base.js
CHANGED
|
@@ -5,6 +5,7 @@ const dateObject = require('./date_object')
|
|
|
5
5
|
* @param {Object} [options]
|
|
6
6
|
*/
|
|
7
7
|
function baseObject ({
|
|
8
|
+
entityName = 'entity',
|
|
8
9
|
splitDate = false
|
|
9
10
|
} = {}) {
|
|
10
11
|
const dateType = splitDate ? dateObject : {
|
|
@@ -15,18 +16,18 @@ function baseObject ({
|
|
|
15
16
|
|
|
16
17
|
return {
|
|
17
18
|
id: {
|
|
18
|
-
description:
|
|
19
|
+
description: `Unique ${entityName} ID`,
|
|
19
20
|
type: 'string',
|
|
20
21
|
format: 'uuid',
|
|
21
22
|
example: '936835f7-2d75-41d2-9001-38ed6e458328'
|
|
22
23
|
},
|
|
23
24
|
created_at: {
|
|
24
25
|
...dateType,
|
|
25
|
-
description:
|
|
26
|
+
description: `The date and time ${entityName} was created`
|
|
26
27
|
},
|
|
27
28
|
updated_at: {
|
|
28
29
|
...dateType,
|
|
29
|
-
description:
|
|
30
|
+
description: `The date and time ${entityName} was updated`
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
33
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module.exports.getEvent = function getEvent (payload) {
|
|
2
|
+
return {
|
|
3
|
+
description: 'The webhook data set',
|
|
4
|
+
type: 'object',
|
|
5
|
+
additionalProperties: false,
|
|
6
|
+
properties: {
|
|
7
|
+
webhookId: {
|
|
8
|
+
description: 'The webhook UUID',
|
|
9
|
+
example: 'ff30cfdf-5167-4f72-b4fc-c1d72db3c07e',
|
|
10
|
+
type: 'string',
|
|
11
|
+
format: 'uuid'
|
|
12
|
+
},
|
|
13
|
+
eventId: {
|
|
14
|
+
description: 'The event UUID',
|
|
15
|
+
example: 'c6fe918a-7bdc-4ccd-af36-95c03853233d',
|
|
16
|
+
type: 'string',
|
|
17
|
+
format: 'uuid'
|
|
18
|
+
},
|
|
19
|
+
eventEntity: {
|
|
20
|
+
description: 'The entity name the event refers to',
|
|
21
|
+
example: 'transaction',
|
|
22
|
+
type: 'string'
|
|
23
|
+
},
|
|
24
|
+
eventType: {
|
|
25
|
+
description: 'The event type (e.g. create, update, delete)',
|
|
26
|
+
example: 'create',
|
|
27
|
+
type: 'string'
|
|
28
|
+
},
|
|
29
|
+
eventVersion: {
|
|
30
|
+
description: 'The event payload version',
|
|
31
|
+
example: 0,
|
|
32
|
+
type: 'number'
|
|
33
|
+
},
|
|
34
|
+
entityInstanceId: {
|
|
35
|
+
description: 'The entity instance UUID',
|
|
36
|
+
example: '10b06f38-031d-4e0c-8706-0474c8c5b61c',
|
|
37
|
+
type: 'string',
|
|
38
|
+
format: 'uuid'
|
|
39
|
+
},
|
|
40
|
+
timestamp: {
|
|
41
|
+
description: 'The date and time event was received by webhooks service',
|
|
42
|
+
example: new Date().toISOString(),
|
|
43
|
+
type: 'string',
|
|
44
|
+
format: 'date-time'
|
|
45
|
+
},
|
|
46
|
+
payload
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -1,11 +1,16 @@
|
|
|
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/wenhooks')
|
|
4
5
|
const baseProduct = require('../../v1/products/base').response
|
|
5
6
|
const baseBranch = require('../../v0/branches/base')
|
|
7
|
+
const baseReason = require('../../v0/reasons/base')
|
|
6
8
|
const baseStockBook = require('./base').simple
|
|
7
9
|
|
|
8
|
-
const eventBaseData = pick(
|
|
10
|
+
const eventBaseData = pick({
|
|
11
|
+
...baseObject({ entityName: 'stock book' }),
|
|
12
|
+
...baseStockBook
|
|
13
|
+
}, ['id', 'created_at', 'qty_change', 'type', 'channel'])
|
|
9
14
|
|
|
10
15
|
const eventOverrideData = {
|
|
11
16
|
product: {
|
|
@@ -16,10 +21,10 @@ const eventOverrideData = {
|
|
|
16
21
|
...baseObject(),
|
|
17
22
|
...baseProduct
|
|
18
23
|
}, [
|
|
19
|
-
'id',
|
|
20
24
|
'name',
|
|
21
25
|
'client_id',
|
|
22
|
-
'custom_id'
|
|
26
|
+
'custom_id',
|
|
27
|
+
'custom_properties'
|
|
23
28
|
])
|
|
24
29
|
},
|
|
25
30
|
location: {
|
|
@@ -30,7 +35,6 @@ const eventOverrideData = {
|
|
|
30
35
|
...baseObject(),
|
|
31
36
|
...baseBranch
|
|
32
37
|
}, [
|
|
33
|
-
'id',
|
|
34
38
|
'name',
|
|
35
39
|
'custom_id',
|
|
36
40
|
'branch_number',
|
|
@@ -39,7 +43,15 @@ const eventOverrideData = {
|
|
|
39
43
|
},
|
|
40
44
|
reason: oneOf({
|
|
41
45
|
description: 'The reason of stock book',
|
|
42
|
-
type: '
|
|
46
|
+
type: 'object',
|
|
47
|
+
additionalProperties: false,
|
|
48
|
+
properties: pick({
|
|
49
|
+
...baseObject(),
|
|
50
|
+
...baseReason
|
|
51
|
+
}, [
|
|
52
|
+
'name',
|
|
53
|
+
'type'
|
|
54
|
+
])
|
|
43
55
|
})
|
|
44
56
|
}
|
|
45
57
|
|
|
@@ -47,18 +59,19 @@ module.exports = {
|
|
|
47
59
|
event: {
|
|
48
60
|
$id: 'https://schemas.tillhub.com/v0/stocks-book.create.event.schema.json',
|
|
49
61
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
62
|
+
...getEvent({
|
|
63
|
+
type: 'object',
|
|
64
|
+
additionalProperties: false,
|
|
65
|
+
required: [
|
|
66
|
+
'id',
|
|
67
|
+
'qty_change',
|
|
68
|
+
'product',
|
|
69
|
+
'location'
|
|
70
|
+
],
|
|
71
|
+
properties: {
|
|
72
|
+
...eventBaseData,
|
|
73
|
+
...eventOverrideData
|
|
74
|
+
}
|
|
75
|
+
})
|
|
63
76
|
}
|
|
64
77
|
}
|