@tillhub/schemas 6.181.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 CHANGED
@@ -1,3 +1,10 @@
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
+
1
8
  # [6.181.0](https://github.com/tillhub/schemas/compare/v6.180.0...v6.181.0) (2022-12-12)
2
9
 
3
10
 
@@ -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,14 +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
10
  const eventBaseData = pick({
9
11
  ...baseObject({ entityName: 'stock book' }),
10
12
  ...baseStockBook
11
- }, ['id', 'qty_change', 'type'])
13
+ }, ['id', 'created_at', 'qty_change', 'type', 'channel'])
12
14
 
13
15
  const eventOverrideData = {
14
16
  product: {
@@ -19,10 +21,10 @@ const eventOverrideData = {
19
21
  ...baseObject(),
20
22
  ...baseProduct
21
23
  }, [
22
- 'id',
23
24
  'name',
24
25
  'client_id',
25
- 'custom_id'
26
+ 'custom_id',
27
+ 'custom_properties'
26
28
  ])
27
29
  },
28
30
  location: {
@@ -33,7 +35,6 @@ const eventOverrideData = {
33
35
  ...baseObject(),
34
36
  ...baseBranch
35
37
  }, [
36
- 'id',
37
38
  'name',
38
39
  'custom_id',
39
40
  'branch_number',
@@ -42,7 +43,15 @@ const eventOverrideData = {
42
43
  },
43
44
  reason: oneOf({
44
45
  description: 'The reason of stock book',
45
- type: 'string'
46
+ type: 'object',
47
+ additionalProperties: false,
48
+ properties: pick({
49
+ ...baseObject(),
50
+ ...baseReason
51
+ }, [
52
+ 'name',
53
+ 'type'
54
+ ])
46
55
  })
47
56
  }
48
57
 
@@ -50,17 +59,19 @@ module.exports = {
50
59
  event: {
51
60
  $id: 'https://schemas.tillhub.com/v0/stocks-book.create.event.schema.json',
52
61
  $schema: 'http://json-schema.org/draft-07/schema#',
53
- type: 'object',
54
- additionalProperties: false,
55
- required: [
56
- 'id',
57
- 'qty_change',
58
- 'product',
59
- 'location'
60
- ],
61
- properties: {
62
- ...eventBaseData,
63
- ...eventOverrideData
64
- }
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
+ })
65
76
  }
66
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tillhub/schemas",
3
- "version": "6.181.0",
3
+ "version": "6.182.0",
4
4
  "private": false,
5
5
  "description": "All Tillhub API OpenAPI 3 compatible JSON Schemas.",
6
6
  "main": "./lib/index.js",