@tillhub/schemas 6.126.0 → 6.129.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,30 @@
1
+ # [6.129.0](https://github.com/tillhub/schemas/compare/v6.128.0...v6.129.0) (2022-03-21)
2
+
3
+
4
+ ### Features
5
+
6
+ * **reasons:** add type "POS price change" #API-1409 ([#683](https://github.com/tillhub/schemas/issues/683)) ([1de76ff](https://github.com/tillhub/schemas/commit/1de76ff)), closes [#API-1409](https://github.com/tillhub/schemas/issues/API-1409) [#API-1409](https://github.com/tillhub/schemas/issues/API-1409)
7
+
8
+ # [6.128.0](https://github.com/tillhub/schemas/compare/v6.127.0...v6.128.0) (2022-03-18)
9
+
10
+
11
+ ### Features
12
+
13
+ * **branches:** add receipt_footer_image to branches model ([#682](https://github.com/tillhub/schemas/issues/682)) ([132523f](https://github.com/tillhub/schemas/commit/132523f))
14
+
15
+ # [6.127.0](https://github.com/tillhub/schemas/compare/v6.126.0...v6.127.0) (2022-03-15)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * **functions:** vouchers ([caa53d9](https://github.com/tillhub/schemas/commit/caa53d9))
21
+
22
+
23
+ ### Features
24
+
25
+ * **functions:** discounted_voucher ([f8ed802](https://github.com/tillhub/schemas/commit/f8ed802))
26
+ * **transactions:** references ([4a70818](https://github.com/tillhub/schemas/commit/4a70818))
27
+
1
28
  # [6.126.0](https://github.com/tillhub/schemas/compare/v6.125.0...v6.126.0) (2022-03-15)
2
29
 
3
30
 
@@ -1,8 +1,18 @@
1
+ const dateObject = require('./date_object')
2
+
1
3
  /**
2
4
  * Create common base object
3
5
  * @param {Object} [options]
4
6
  */
5
- function baseObject (options = {}) {
7
+ function baseObject ({
8
+ splitDate = false
9
+ } = {}) {
10
+ const dateType = splitDate ? dateObject : {
11
+ type: 'string',
12
+ format: 'date-time',
13
+ example: '2019-03-17T21:12:04.849Z'
14
+ }
15
+
6
16
  return {
7
17
  id: {
8
18
  description: 'Unique entity ID',
@@ -11,16 +21,12 @@ function baseObject (options = {}) {
11
21
  example: '936835f7-2d75-41d2-9001-38ed6e458328'
12
22
  },
13
23
  created_at: {
14
- description: 'The date and time entity was created',
15
- type: 'string',
16
- format: 'date-time',
17
- example: '2019-03-17T21:12:04.849Z'
24
+ ...dateType,
25
+ description: 'The date and time entity was created'
18
26
  },
19
27
  updated_at: {
20
- description: 'The date and time entity was updated',
21
- type: 'string',
22
- format: 'date-time',
23
- example: '2019-03-17T21:12:04.849Z'
28
+ ...dateType,
29
+ description: 'The date and time entity was updated'
24
30
  }
25
31
  }
26
32
  }
@@ -1,3 +1,5 @@
1
+ const { anyOf } = require('../helpers/payload-or-null')
2
+
1
3
  const definedSizes = {
2
4
  '1x': {
3
5
  description: 'Image transformed to predefined small size',
@@ -31,7 +33,11 @@ const definedSizes = {
31
33
  }
32
34
  }
33
35
 
34
- function getImages (sizes = ['1x', '2x', '3x', 'avatar'], strict = false) {
36
+ const getImages = ({
37
+ sizes = ['1x', '2x', '3x', 'avatar'],
38
+ strict = false,
39
+ description = 'Images object with URLs of various types of images'
40
+ }) => {
35
41
  const sizesMap = sizes.reduce((memo, size) => {
36
42
  if (!definedSizes[size]) {
37
43
  throw new ReferenceError(`Size '${size}' is not defined`)
@@ -42,8 +48,8 @@ function getImages (sizes = ['1x', '2x', '3x', 'avatar'], strict = false) {
42
48
  }, {})
43
49
 
44
50
  return {
45
- description: 'Images object with URLs of various types of images',
46
- anyOf: [{
51
+ description,
52
+ ...anyOf({
47
53
  type: 'object',
48
54
  additionalProperties: !strict,
49
55
  properties: {
@@ -54,9 +60,8 @@ function getImages (sizes = ['1x', '2x', '3x', 'avatar'], strict = false) {
54
60
  type: 'string',
55
61
  format: 'uri'
56
62
  }
57
- } }, {
58
- type: 'null'
59
- }]
63
+ }
64
+ })
60
65
  }
61
66
  }
62
67
 
@@ -124,7 +124,12 @@ module.exports = {
124
124
  }
125
125
  ]
126
126
  },
127
- images: getImages(),
127
+ images: getImages({
128
+ description: 'A Tillhub image object with URLs to display images this for this branch.'
129
+ }),
130
+ receipt_footer_images: getImages({
131
+ description: 'A Tillhub image object with URLs to display receipt footer image this for this branch.'
132
+ }),
128
133
  image: {
129
134
  description: 'DEPRECATED. Omit or set null.',
130
135
  anyOf: [
@@ -154,7 +154,7 @@ module.exports = {
154
154
  format: 'date-time'
155
155
  })
156
156
  },
157
- images: getImages(['1x', '2x', '3x', 'avatar', 'gallery']),
157
+ images: getImages({ sizes: ['1x', '2x', '3x', 'avatar', 'gallery'] }),
158
158
  image: {
159
159
  description: 'DEPRECATED. Omit or set null.',
160
160
  ...anyOf({
@@ -59,7 +59,7 @@ const linkedVoucherPayload = {
59
59
  additionalProperties: false,
60
60
  type: 'object',
61
61
  required: [
62
- 'products'
62
+ 'linked_voucher'
63
63
  ],
64
64
  properties: {
65
65
  linked_voucher: {
@@ -120,6 +120,59 @@ const linkedVoucherPayload = {
120
120
  }
121
121
  }
122
122
 
123
+ const discountedVoucherPayload = {
124
+ description: 'Specific description of the discounted voucher function (1 specific voucher added together with a negative amount product).',
125
+ additionalProperties: false,
126
+ type: 'object',
127
+ required: [
128
+ 'discounted_voucher'
129
+ ],
130
+ properties: {
131
+ discounted_voucher: {
132
+ type: 'object',
133
+ description: 'Describes the necessary fields to sell voucher that is discounted by an additional product.',
134
+ additionalProperties: false,
135
+ properties: {
136
+ action: {
137
+ type: 'string',
138
+ format: 'uuid',
139
+ description: 'The primaray voucher action ressource ID.',
140
+ example: 'efe039d8-e38d-4333-86d8-48334da189a8'
141
+ },
142
+ amount: {
143
+ example: 50.0,
144
+ description: 'The primaray voucher amount (.2Decimal e.g. 50.00€).',
145
+ type: 'number',
146
+ minimum: 0,
147
+ maximum: 1000000,
148
+ multipleOf: 0.01
149
+ },
150
+ linked_product: {
151
+ type: 'string',
152
+ format: 'uuid',
153
+ description: 'The additional product ressource ID.',
154
+ example: 'fc7cc46a-ebe2-4b62-9b1b-0f849680b49'
155
+ },
156
+ linked_amount: {
157
+ example: 10.0,
158
+ description: 'The unit price of the linked product.',
159
+ type: 'number',
160
+ minimum: 0,
161
+ maximum: 1000000,
162
+ multipleOf: 0.01
163
+ },
164
+ linked_quantity: {
165
+ example: -1,
166
+ description: 'The quantity of the linked product (typically -1) to act as a discount.',
167
+ type: 'integer',
168
+ minimum: -16,
169
+ maximum: 0
170
+ }
171
+ }
172
+ }
173
+ }
174
+ }
175
+
123
176
  const configurationProperties = {
124
177
  description: {
125
178
  oneOf: [
@@ -327,50 +380,74 @@ module.exports = {
327
380
  enum: [
328
381
  'instant_checkout',
329
382
  'add_to_cart',
330
- 'linked_voucher'
383
+ 'linked_voucher',
384
+ 'discounted_voucher'
331
385
  ]
332
386
  }
333
387
  },
334
- if: {
335
- properties: {
336
- class: {
337
- type: 'string',
338
- enum: [
339
- 'instant_checkout',
340
- 'add_to_cart'
341
- ]
342
- }
343
- }
344
- },
345
- then: {
346
- properties: {
347
- ...configurationProperties,
348
- payload: {
349
- ...oneOf(instantCheckoutPayload)
350
- }
351
- }
352
- },
353
- else: {
354
- if: {
355
- properties: {
356
- class: {
357
- type: 'string',
358
- enum: [
359
- 'linked_voucher'
360
- ]
388
+ allOf: [
389
+ {
390
+ if: {
391
+ properties: {
392
+ class: {
393
+ type: 'string',
394
+ enum: [
395
+ 'instant_checkout',
396
+ 'add_to_cart'
397
+ ]
398
+ }
399
+ }
400
+ },
401
+ then: {
402
+ properties: {
403
+ ...configurationProperties,
404
+ payload: {
405
+ ...oneOf(instantCheckoutPayload)
406
+ }
361
407
  }
362
408
  }
363
409
  },
364
- then: {
365
- properties: {
366
- ...configurationProperties,
367
- payload: {
368
- ...oneOf(linkedVoucherPayload)
410
+ {
411
+ if: {
412
+ properties: {
413
+ class: {
414
+ type: 'string',
415
+ enum: [
416
+ 'linked_voucher'
417
+ ]
418
+ }
419
+ }
420
+ },
421
+ then: {
422
+ properties: {
423
+ ...configurationProperties,
424
+ payload: {
425
+ ...oneOf(linkedVoucherPayload)
426
+ }
369
427
  }
370
428
  }
371
429
  },
372
- else: false // further if-else statements add in here, as a nested prop
373
- }
430
+ {
431
+ if: {
432
+ properties: {
433
+ class: {
434
+ type: 'string',
435
+ enum: [
436
+ 'discounted_voucher'
437
+ ]
438
+ }
439
+ }
440
+ },
441
+ then: {
442
+ properties: {
443
+ ...configurationProperties,
444
+ payload: {
445
+ ...oneOf(discountedVoucherPayload)
446
+ }
447
+ }
448
+ }
449
+ }
450
+ ]
374
451
  },
375
452
  locations: {
376
453
  anyOf: [
@@ -3,6 +3,8 @@ const { oneOf } = require('../../helpers/payload-or-null')
3
3
  module.exports = {
4
4
  name: {
5
5
  ...oneOf([{
6
+ description: 'The reason name',
7
+ example: 'Returned goods',
6
8
  type: 'string',
7
9
  minLength: 1,
8
10
  maxLength: 128
@@ -10,6 +12,8 @@ module.exports = {
10
12
  },
11
13
  description: {
12
14
  ...oneOf([{
15
+ description: 'The reason description',
16
+ example: 'Goods were returned by the customer',
13
17
  type: 'string',
14
18
  minLength: 1,
15
19
  maxLength: 4096
@@ -56,26 +60,33 @@ module.exports = {
56
60
  type: 'boolean'
57
61
  },
58
62
  active: {
63
+ description: 'The reason is active',
59
64
  type: 'boolean'
60
65
  },
61
66
  type: {
67
+ description: 'The reason type',
68
+ example: 'expense',
62
69
  type: 'string',
63
70
  enum: [
64
71
  'refund',
72
+ 'pos_price_change',
65
73
  'stock_change',
66
74
  'expense',
67
75
  'deposit'
68
76
  ]
69
77
  },
70
78
  noted_required: {
79
+ description: 'The action must be noted',
71
80
  type: 'boolean',
72
81
  default: false
73
82
  },
74
83
  image_required: {
84
+ description: 'The image must be enclosed',
75
85
  type: 'boolean',
76
86
  default: false
77
87
  },
78
88
  approval_required: {
89
+ description: 'The action must be approved by supervisor',
79
90
  type: 'boolean',
80
91
  default: false
81
92
  }
@@ -1,5 +1,5 @@
1
+ const baseObject = require('../../common/base')
1
2
  const base = require('./base')
2
- const defaultResponse = require('./default-response')
3
3
 
4
4
  module.exports.request = {
5
5
  $id: 'https://schemas.tillhub.com/v0/reasons.create.request.schema.json',
@@ -22,5 +22,8 @@ module.exports.response = {
22
22
  'id',
23
23
  'name'
24
24
  ],
25
- properties: defaultResponse
25
+ properties: {
26
+ ...baseObject(),
27
+ ...base
28
+ }
26
29
  }
@@ -1,2 +1,3 @@
1
1
  module.exports.create = require('./create')
2
+ module.exports.read = require('./read')
2
3
  module.exports.update = require('./update')
@@ -0,0 +1,38 @@
1
+ const baseObject = require('../../common/base')
2
+ const commonResponse = require('../../common/response')
3
+
4
+ const base = require('./base')
5
+
6
+ module.exports.all = {
7
+ response: {
8
+ $id: 'https://schemas.tillhub.com/v0/reasons.read.all.response.schema.json',
9
+ $schema: 'http://json-schema.org/draft-07/schema#',
10
+ ...commonResponse({
11
+ resultItems: {
12
+ type: 'object',
13
+ additionalProperties: false,
14
+ properties: {
15
+ ...baseObject({ splitDate: true }),
16
+ ...base
17
+ }
18
+ }
19
+ })
20
+ }
21
+ }
22
+
23
+ module.exports.one = {
24
+ response: {
25
+ $id: 'https://schemas.tillhub.com/v0/reasons.read.one.response.schema.json',
26
+ $schema: 'http://json-schema.org/draft-07/schema#',
27
+ ...commonResponse({
28
+ resultItems: {
29
+ type: 'object',
30
+ additionalProperties: false,
31
+ properties: {
32
+ ...baseObject({ splitDate: true }),
33
+ ...base
34
+ }
35
+ }
36
+ })
37
+ }
38
+ }
@@ -1,5 +1,5 @@
1
+ const baseObject = require('../../common/base')
1
2
  const base = require('./base')
2
- const defaultResponse = require('./default-response')
3
3
 
4
4
  module.exports.request = {
5
5
  $id: 'https://schemas.tillhub.com/v0/reasons.update.request.schema.json',
@@ -18,5 +18,8 @@ module.exports.response = {
18
18
  required: [
19
19
  'id'
20
20
  ],
21
- properties: defaultResponse
21
+ properties: {
22
+ ...baseObject(),
23
+ ...base
24
+ }
22
25
  }
@@ -19,7 +19,8 @@ module.exports = {
19
19
  'canceled_expense',
20
20
  'canceled_deposit',
21
21
  'canceled_bank_expense',
22
- 'canceled_bank_deposit'
22
+ 'canceled_bank_deposit',
23
+ 'linked_item'
23
24
  ]
24
25
  },
25
26
  id: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tillhub/schemas",
3
- "version": "6.126.0",
3
+ "version": "6.129.0",
4
4
  "private": false,
5
5
  "description": "All Tillhub API OpenAPI 3 compatible JSON Schemas.",
6
6
  "main": "./lib/index.js",
@@ -1,17 +0,0 @@
1
- const base = require('./base')
2
-
3
- module.exports = {
4
- ...base,
5
- id: {
6
- type: 'string',
7
- format: 'uuid'
8
- },
9
- created_at: {
10
- type: 'string',
11
- format: 'date-time'
12
- },
13
- updated_at: {
14
- type: 'string',
15
- format: 'date-time'
16
- }
17
- }