@tillhub/schemas 6.118.0 → 6.121.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.
Files changed (42) hide show
  1. package/CHANGELOG.md +33 -0
  2. package/lib/common/address.js +67 -82
  3. package/lib/common/base.js +3 -0
  4. package/lib/common/images.js +63 -0
  5. package/lib/common/query.js +64 -0
  6. package/lib/common/response.js +11 -10
  7. package/lib/v0/audits/index.js +3 -0
  8. package/lib/v0/audits/logs/base.js +81 -0
  9. package/lib/v0/audits/logs/index.js +3 -0
  10. package/lib/v0/audits/logs/read.js +30 -0
  11. package/lib/v0/branches/base.js +55 -63
  12. package/lib/v0/branches/create.js +18 -0
  13. package/lib/v0/branches/index.js +1 -0
  14. package/lib/v0/branches/read.js +119 -0
  15. package/lib/v0/branches/update.js +18 -0
  16. package/lib/v0/category_trees/definitions.js +1 -1
  17. package/lib/v0/customers/base.js +352 -576
  18. package/lib/v0/customers/baseExt.js +35 -0
  19. package/lib/v0/customers/create.js +41 -0
  20. package/lib/v0/customers/ext.js +113 -7
  21. package/lib/v0/customers/index.js +18 -50
  22. package/lib/v0/customers/properties/anaylytics.js +7 -7
  23. package/lib/v0/customers/read.js +42 -0
  24. package/lib/v0/customers/update.js +30 -0
  25. package/lib/v0/deliveries/base.js +3 -3
  26. package/lib/v0/index.js +1 -0
  27. package/lib/v0/orders/create.request.js +3 -3
  28. package/lib/v0/pdfs/templates.deliveries.create.request.js +3 -7
  29. package/lib/v0/pdfs/templates.delivery_notes.create.request.js +3 -7
  30. package/lib/v0/pdfs/templates.full_receipts.create.request.js +3 -7
  31. package/lib/v0/pdfs/templates.invoices.create.request.js +3 -7
  32. package/lib/v0/pdfs/templates.transaction_receipts.create.request.js +3 -7
  33. package/lib/v1/branches/index.js +1 -0
  34. package/lib/v1/branches/read.js +16 -0
  35. package/lib/v1/index.js +6 -5
  36. package/package.json +1 -1
  37. package/test/audits/logs/logs.spec.js +11 -0
  38. package/test/branches/branches.v0.spec.js +50 -11
  39. package/test/branches/branches.v1.spec.js +19 -0
  40. package/test/customers/customers.v0.spec.js +93 -5
  41. package/lib/v0/customers/create.request.js +0 -24
  42. package/lib/v0/customers/update.request.js +0 -14
package/CHANGELOG.md CHANGED
@@ -1,3 +1,36 @@
1
+ # [6.121.0](https://github.com/tillhub/schemas/compare/v6.120.0...v6.121.0) (2022-02-21)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **tests:** remove require() errors ([f2b6a16](https://github.com/tillhub/schemas/commit/f2b6a16))
7
+
8
+
9
+ ### Features
10
+
11
+ * **customers:** add rmissing schemas #API-1393 ([#672](https://github.com/tillhub/schemas/issues/672)) ([a4b8f30](https://github.com/tillhub/schemas/commit/a4b8f30)), closes [#API-1393](https://github.com/tillhub/schemas/issues/API-1393) [#API-1393](https://github.com/tillhub/schemas/issues/API-1393)
12
+
13
+ # [6.120.0](https://github.com/tillhub/schemas/compare/v6.119.0...v6.120.0) (2022-02-17)
14
+
15
+
16
+ ### Features
17
+
18
+ * **branches:** add detailed branches schema #API-1392 ([#671](https://github.com/tillhub/schemas/issues/671)) ([3232d2b](https://github.com/tillhub/schemas/commit/3232d2b)), closes [#API-1392](https://github.com/tillhub/schemas/issues/API-1392) [#API-1392](https://github.com/tillhub/schemas/issues/API-1392)
19
+
20
+ # [6.119.0](https://github.com/tillhub/schemas/compare/v6.118.1...v6.119.0) (2022-02-15)
21
+
22
+
23
+ ### Features
24
+
25
+ * **audits:** add audit logs response schema #API-1331 ([#668](https://github.com/tillhub/schemas/issues/668)) ([057c73e](https://github.com/tillhub/schemas/commit/057c73e)), closes [#API-1331](https://github.com/tillhub/schemas/issues/API-1331) [#API-1331](https://github.com/tillhub/schemas/issues/API-1331)
26
+
27
+ ## [6.118.1](https://github.com/tillhub/schemas/compare/v6.118.0...v6.118.1) (2022-02-14)
28
+
29
+
30
+ ### Bug Fixes
31
+
32
+ * **docs:** fixing the children type on category_trees ([141dc8e](https://github.com/tillhub/schemas/commit/141dc8e))
33
+
1
34
  # [6.118.0](https://github.com/tillhub/schemas/compare/v6.117.1...v6.118.0) (2022-02-10)
2
35
 
3
36
 
@@ -1,7 +1,7 @@
1
- module.exports = {
2
- type: 'object',
3
- additionalProperties: false,
4
- required: [
1
+ const { oneOf } = require('../helpers/payload-or-null')
2
+
3
+ function getAddress ({
4
+ required = [
5
5
  'lines',
6
6
  'street',
7
7
  'locality',
@@ -10,10 +10,21 @@ module.exports = {
10
10
  'country',
11
11
  'type'
12
12
  ],
13
- properties: {
14
- lines: {
15
- oneOf: [
16
- {
13
+ availableTypes = [
14
+ 'local',
15
+ 'delivery',
16
+ 'billing'
17
+ ]
18
+ } = {}) {
19
+ return {
20
+ type: 'object',
21
+ additionalProperties: false,
22
+ required,
23
+ properties: {
24
+ lines: {
25
+ description: 'Address details',
26
+ example: 'Penthouse',
27
+ ...oneOf({
17
28
  type: 'array',
18
29
  minItems: 1,
19
30
  maxItems: 4,
@@ -21,91 +32,65 @@ module.exports = {
21
32
  type: 'string',
22
33
  minLength: 1
23
34
  }
24
- },
25
- {
26
- type: 'null'
27
- }
28
- ]
29
- },
30
- street: {
31
- oneOf: [
32
- {
35
+ })
36
+ },
37
+ street: {
38
+ description: 'Street name',
39
+ example: 'Genthiner Str.',
40
+ ...oneOf({
33
41
  type: 'string'
34
- },
35
- {
36
- type: 'null'
37
- }
38
- ]
39
- },
40
- street_number: {
41
- oneOf: [
42
- {
42
+ })
43
+ },
44
+ street_number: {
45
+ description: 'Building number',
46
+ example: '34',
47
+ ...oneOf({
43
48
  type: 'string'
44
- },
45
- {
46
- type: 'null'
47
- }
48
- ]
49
- },
50
- locality: {
51
- oneOf: [
52
- {
49
+ })
50
+ },
51
+ locality: {
52
+ description: 'Locality name (city, village, etc.)',
53
+ example: 'Berlin',
54
+ ...oneOf({
53
55
  type: 'string'
54
- },
55
- {
56
- type: 'null'
57
- }
58
- ]
59
- },
60
- region: {
61
- oneOf: [
62
- {
56
+ })
57
+ },
58
+ region: {
59
+ description: 'Region name',
60
+ example: 'Branderburg',
61
+ ...oneOf({
63
62
  type: 'string'
64
- },
65
- {
66
- type: 'null'
67
- }
68
- ]
69
- },
70
- postal_code: {
71
- oneOf: [
72
- {
63
+ })
64
+ },
65
+ postal_code: {
66
+ description: 'Postal code',
67
+ example: '10785',
68
+ ...oneOf({
73
69
  type: 'string',
74
70
  maxLength: 10
75
- },
76
- {
77
- type: 'null'
78
- }
79
- ]
80
- },
81
- country: {
82
- oneOf: [
83
- {
71
+ })
72
+ },
73
+ country: {
74
+ description: 'Country',
75
+ example: 'Germany',
76
+ ...oneOf({
84
77
  type: 'string',
85
78
  minLength: 2,
86
79
  maxLength: 2,
87
80
  pattern: '^[A-Z]{2}$'
88
- },
89
- {
90
- type: 'null'
91
- }
92
- ],
93
- 'default': null
94
- },
95
- type: {
96
- oneOf: [
97
- {
81
+ }),
82
+ 'default': null
83
+ },
84
+ type: {
85
+ description: 'Address type',
86
+ example: 'delivery',
87
+ ...oneOf({
98
88
  type: 'string',
99
- 'enum': [
100
- 'local',
101
- 'delivery',
102
- 'billing'
103
- ]
104
- },
105
- {
106
- type: 'null'
107
- }
108
- ]
89
+ 'enum': availableTypes
90
+ })
91
+ }
109
92
  }
110
93
  }
111
94
  }
95
+
96
+ module.exports = { getAddress }
@@ -5,16 +5,19 @@
5
5
  function baseObject (options = {}) {
6
6
  return {
7
7
  id: {
8
+ description: 'Unique entity ID',
8
9
  type: 'string',
9
10
  format: 'uuid',
10
11
  example: '936835f7-2d75-41d2-9001-38ed6e458328'
11
12
  },
12
13
  created_at: {
14
+ description: 'The date and time entity was created',
13
15
  type: 'string',
14
16
  format: 'date-time',
15
17
  example: '2019-03-17T21:12:04.849Z'
16
18
  },
17
19
  updated_at: {
20
+ description: 'The date and time entity was updated',
18
21
  type: 'string',
19
22
  format: 'date-time',
20
23
  example: '2019-03-17T21:12:04.849Z'
@@ -0,0 +1,63 @@
1
+ const definedSizes = {
2
+ '1x': {
3
+ description: 'Image transformed to predefined small size',
4
+ example: 'https://my-storage.io/images/f5a3cc72-7fb5-4d2c-bda5-9b2983c7e879_1x.png',
5
+ type: 'string',
6
+ format: 'uri'
7
+ },
8
+ '2x': {
9
+ description: 'Image transformed to predefined medium size',
10
+ example: 'https://my-storage.io/images/f5a3cc72-7fb5-4d2c-bda5-9b2983c7e879_2x.png',
11
+ type: 'string',
12
+ format: 'uri'
13
+ },
14
+ '3x': {
15
+ description: 'Image transformed to predefined big size',
16
+ example: 'https://my-storage.io/images/f5a3cc72-7fb5-4d2c-bda5-9b2983c7e879_1x.png',
17
+ type: 'string',
18
+ format: 'uri'
19
+ },
20
+ gallery: {
21
+ description: 'Image transformed to predefined size to use in gallery',
22
+ example: 'https://my-storage.io/images/f5a3cc72-7fb5-4d2c-bda5-9b2983c7e879_gallery.png',
23
+ type: 'string',
24
+ format: 'uri'
25
+ },
26
+ avatar: {
27
+ description: 'Image transformed to predefined size to use as "avatar"',
28
+ example: 'https://my-storage.io/images/f5a3cc72-7fb5-4d2c-bda5-9b2983c7e879_avatar.png',
29
+ type: 'string',
30
+ format: 'uri'
31
+ }
32
+ }
33
+
34
+ function getImages (sizes = ['1x', '2x', '3x', 'avatar'], strict = false) {
35
+ const sizesMap = sizes.reduce((memo, size) => {
36
+ if (!definedSizes[size]) {
37
+ throw new ReferenceError(`Size '${size}' is not defined`)
38
+ }
39
+
40
+ memo[size] = { ...definedSizes[size] }
41
+ return memo
42
+ }, {})
43
+
44
+ return {
45
+ description: 'Images object with URLs of various types of images',
46
+ anyOf: [{
47
+ type: 'object',
48
+ additionalProperties: !strict,
49
+ properties: {
50
+ ...sizesMap,
51
+ original: {
52
+ description: 'Original image',
53
+ example: 'https://my-storage.io/images/f5a3cc72-7fb5-4d2c-bda5-9b2983c7e879.png',
54
+ type: 'string',
55
+ format: 'uri'
56
+ }
57
+ } }, {
58
+ type: 'null'
59
+ }]
60
+ }
61
+ }
62
+
63
+ module.exports = { getImages }
@@ -0,0 +1,64 @@
1
+ const standardParams = {
2
+ start: {
3
+ description: 'The start date to filter entities by "updated_at" field value',
4
+ example: '2022-02-01T00:00:00.000Z',
5
+ type: 'string',
6
+ format: 'date-time'
7
+ },
8
+ end: {
9
+ description: 'The end date to filter entities by "updated_at" field value',
10
+ example: '2022-02-28T23:59:59.999Z',
11
+ type: 'string',
12
+ format: 'date-time'
13
+ },
14
+ limit: {
15
+ description: 'The maximum amount of entries on page (for paginated output)',
16
+ example: 50,
17
+ type: 'integer',
18
+ minimum: 1
19
+ },
20
+ active: {
21
+ description: 'Filter entities by "active" field value',
22
+ example: 'true',
23
+ type: 'string',
24
+ enum: ['true', 'false']
25
+ },
26
+ deleted: {
27
+ description: 'Filter entities which are deleted or not',
28
+ example: 'true',
29
+ type: 'string',
30
+ enum: ['true', 'false']
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Generate a common query for entities set
36
+ * @param {Object} required Required fields to restrict the amount of entries
37
+ */
38
+ function getQuery ({
39
+ standard = ['start', 'end'],
40
+ required = ['start', 'end'],
41
+ additional = {}
42
+ } = {}) {
43
+ const properties = standard.reduce((memo, paramName) => {
44
+ if (!standardParams[paramName]) {
45
+ throw new ReferenceError(`Parameter '${paramName}' is not standard`)
46
+ }
47
+
48
+ memo[paramName] = { ...standardParams[paramName] }
49
+
50
+ return memo
51
+ }, {})
52
+
53
+ Object.assign(properties, additional)
54
+
55
+ return {
56
+ $schema: 'http://json-schema.org/draft-07/schema#',
57
+ additionalProperties: false,
58
+ type: 'object',
59
+ required,
60
+ properties
61
+ }
62
+ }
63
+
64
+ module.exports = getQuery
@@ -1,25 +1,26 @@
1
1
  const cursor = {
2
2
  type: 'object',
3
+ description: 'Optional cursor in paginated API calls. The cursor next field must be called as fully quantifiable URI in order to hit the next if available.',
3
4
  additionalProperties: false,
4
- description: 'Optional cursor in pagable API calls. The cursor next field must be called as fully qualifyable URI in order to hit the next page',
5
+ required: ['self'],
5
6
  properties: {
6
7
  next: {
7
8
  type: 'string',
8
9
  format: 'uri',
9
10
  description: 'The URI pointing to the next page.',
10
- example: 'https://api.tillhub.com/api/v1/products/061f91a3-eba2-40b8-9a76-115189d6741e?first=2018-07-02T21%3A47%3A44.382Z&page=0&size=10&cursor_field=updated_at'
11
+ example: 'https://api.tillhub.com/api/v1/products/061f91a3-eba2-40b8-9a76-115189d6741e?cursor=2018-07-02T21%3A47%3A44.382Z&size=10&cursor_field=updated_at'
11
12
  },
12
13
  first: {
13
14
  type: 'string',
14
15
  format: 'uri',
15
16
  description: 'The URI pointing to the the first page.',
16
- example: 'https://api.tillhub.com/api/v1/products/061f91a3-eba2-40b8-9a76-115189d6741e?first=2018-07-02T21%3A47%3A44.382Z&page=1&size=10&cursor_field=updated_at'
17
+ example: 'https://api.tillhub.com/api/v1/products/061f91a3-eba2-40b8-9a76-115189d6741e?cursor=2018-07-02T21%3A47%3A44.382Z&size=10&cursor_field=updated_at'
17
18
  },
18
19
  self: {
19
20
  type: 'string',
20
21
  format: 'uri',
21
22
  description: 'The URI pointing to this page.',
22
- example: 'https://api.tillhub.com/api/v1/products/061f91a3-eba2-40b8-9a76-115189d6741e?first=2018-07-02T21%3A47%3A44.382Z&page=0&size=10&cursor_field=updated_at'
23
+ example: 'https://api.tillhub.com/api/v1/products/061f91a3-eba2-40b8-9a76-115189d6741e?cursor=2018-07-02T21%3A47%3A44.382Z&size=10&cursor_field=updated_at'
23
24
  }
24
25
  }
25
26
  }
@@ -47,14 +48,14 @@ function commonResponse ({ resultItems, results, additionals } = {}, { hasCursor
47
48
  msg: {
48
49
  type: 'string',
49
50
  minLength: 1,
50
- example: 'Queried transactions sucessefully.',
51
- description: 'Any English sentence, meant as information for developers and implementers. Avoid displaying this to the users and especially do not expect thos messages to stay stable.'
51
+ example: 'Queried transactions successfully.',
52
+ description: 'Any English sentence, meant as information for developers and implementers. Avoid displaying this to the users and especially do not expect those messages to stay stable.'
52
53
  },
53
54
  msg_localised: {
55
+ description: 'Optional localized message that can be displayed to the user if existing. The language can be set by in the request or will fallback to English.',
56
+ example: 'Abgefragte Transaktionen erfolgreich.',
54
57
  type: 'string',
55
- minLength: 1,
56
- example: 'Queried transactions sucessefully.',
57
- description: 'Optional localised message that can be displayed to the user if existing. The language can be set by in the request or will fallback to English.'
58
+ minLength: 1
58
59
  },
59
60
  request: {
60
61
  type: 'object',
@@ -84,7 +85,7 @@ function commonResponse ({ resultItems, results, additionals } = {}, { hasCursor
84
85
  }
85
86
  }
86
87
 
87
- if (hasCursor) response.cursor = cursor
88
+ if (hasCursor) response.properties.cursor = cursor
88
89
 
89
90
  return response
90
91
  }
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ logs: require('./logs')
3
+ }
@@ -0,0 +1,81 @@
1
+ const { oneOf } = require('../../../helpers/payload-or-null')
2
+
3
+ const changeEntry = {
4
+ type: 'object',
5
+ additionalProperties: false,
6
+ properties: {
7
+ op: {
8
+ description: 'Operation type',
9
+ type: 'string',
10
+ enum: [
11
+ 'add',
12
+ 'replace',
13
+ 'remove'
14
+ ]
15
+ },
16
+ path: {
17
+ description: 'Changed property path (with dot as separator)',
18
+ type: 'string',
19
+ example: 'images.0.url'
20
+ },
21
+ value: {
22
+ description: 'Changed value',
23
+ type: 'string',
24
+ example: 'This is it'
25
+ }
26
+ }
27
+ }
28
+
29
+ module.exports = {
30
+ type: {
31
+ description: 'Log type (entity type and action type)',
32
+ type: 'string',
33
+ example: 'product.update'
34
+ },
35
+ old: oneOf({
36
+ description: 'Old data',
37
+ type: 'object',
38
+ example: {}
39
+ }),
40
+ new: oneOf({
41
+ description: 'New data',
42
+ type: 'object',
43
+ example: {
44
+ id: '0f91b67b-b1eb-4aba-827a-3a83ff967c5e',
45
+ name: 'Foo bar'
46
+ }
47
+ }),
48
+ change: oneOf({
49
+ description: 'Changes between old and new',
50
+ type: 'array',
51
+ items: changeEntry
52
+ }),
53
+ description: oneOf({
54
+ description: 'Description',
55
+ type: 'string',
56
+ example: 'Login attempt from service account'
57
+ }),
58
+ issuer: oneOf({
59
+ description: 'Issuer data',
60
+ type: 'object',
61
+ properties: {
62
+ sub_user: {
63
+ description: 'Sub-user (person authorized under organization account) UUID',
64
+ type: 'string',
65
+ format: 'uuid',
66
+ example: '8ddb94bf-98cf-4832-9833-c118ebf04675'
67
+ }
68
+ }
69
+ }),
70
+ metadata: oneOf({
71
+ description: 'Metadata',
72
+ type: 'object',
73
+ properties: {
74
+ user_agent: {
75
+ description: 'User-agent data',
76
+ type: 'string',
77
+ example: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36'
78
+ }
79
+ }
80
+ })
81
+ }
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ read: require('./read')
3
+ }
@@ -0,0 +1,30 @@
1
+ const commonBase = { ...require('../../../common/base') }
2
+ const commonResponse = require('../../../common/response')
3
+ const { oneOf } = require('../../../helpers/payload-or-null')
4
+
5
+ const base = require('./base')
6
+
7
+ // Logs are read-only
8
+ delete commonBase.updated_at
9
+
10
+ module.exports.response = {
11
+ $id: 'https://schemas.tillhub.com/v0/audits.logs.read.response.schema.json',
12
+ $schema: 'http://json-schema.org/draft-07/schema#',
13
+ additionalProperties: false,
14
+ ...commonResponse({
15
+ resultItems: {
16
+ type: 'object',
17
+ required: ['id', 'created_at', 'insert_id', 'type'],
18
+ additionalProperties: false,
19
+ properties: {
20
+ ...commonBase,
21
+ insert_id: oneOf({
22
+ description: 'Sequential counter',
23
+ type: 'integer',
24
+ example: 16259
25
+ }),
26
+ ...base
27
+ }
28
+ }
29
+ }, { hasCursor: true })
30
+ }