@tillhub/schemas 6.125.0 → 6.128.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.128.0](https://github.com/tillhub/schemas/compare/v6.127.0...v6.128.0) (2022-03-18)
2
+
3
+
4
+ ### Features
5
+
6
+ * **branches:** add receipt_footer_image to branches model ([#682](https://github.com/tillhub/schemas/issues/682)) ([132523f](https://github.com/tillhub/schemas/commit/132523f))
7
+
8
+ # [6.127.0](https://github.com/tillhub/schemas/compare/v6.126.0...v6.127.0) (2022-03-15)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **functions:** vouchers ([caa53d9](https://github.com/tillhub/schemas/commit/caa53d9))
14
+
15
+
16
+ ### Features
17
+
18
+ * **functions:** discounted_voucher ([f8ed802](https://github.com/tillhub/schemas/commit/f8ed802))
19
+ * **transactions:** references ([4a70818](https://github.com/tillhub/schemas/commit/4a70818))
20
+
21
+ # [6.126.0](https://github.com/tillhub/schemas/compare/v6.125.0...v6.126.0) (2022-03-15)
22
+
23
+
24
+ ### Features
25
+
26
+ * **analytics:** transactons overview report v3 schema #API-1042 ([#680](https://github.com/tillhub/schemas/issues/680)) ([e5dc7ba](https://github.com/tillhub/schemas/commit/e5dc7ba)), closes [#API-1042](https://github.com/tillhub/schemas/issues/API-1042) [#API-1042](https://github.com/tillhub/schemas/issues/API-1042)
27
+
1
28
  # [6.125.0](https://github.com/tillhub/schemas/compare/v6.124.0...v6.125.0) (2022-03-10)
2
29
 
3
30
 
@@ -0,0 +1,68 @@
1
+ const dateObject = require('./date_object')
2
+ const commonResponse = require('./response')
3
+
4
+ /**
5
+ * Generate a common analytics response
6
+ * @param {Array<{job: Object, type: Object}>} metrics
7
+ * @param {Object[]} values
8
+ */
9
+ function analyticsResponse (metrics, values) {
10
+ if (!Array.isArray(metrics)) {
11
+ throw new TypeError('Analytics response requires metrics to be set')
12
+ }
13
+ if (!Array.isArray(values)) {
14
+ throw new TypeError('Analytics response requires values to be set')
15
+ }
16
+ if (metrics.length !== values.length) {
17
+ throw new TypeError('Analytics response requires matrics and values to have the same length')
18
+ }
19
+
20
+ return {
21
+ $schema: 'http://json-schema.org/draft-07/schema#',
22
+ additionalProperties: false,
23
+ ...commonResponse({
24
+ resultItems: {
25
+ anyOf: metrics.map((metric, index) => ({
26
+ type: 'object',
27
+ additionalProperties: false,
28
+ properties: {
29
+ created_at: {
30
+ ...dateObject,
31
+ description: 'Job date'
32
+ },
33
+ metric: {
34
+ description: 'Metric description',
35
+ type: 'object',
36
+ additionalProperties: false,
37
+ properties: {
38
+ user: {
39
+ description: 'Client ID',
40
+ type: 'string',
41
+ format: 'uuid',
42
+ example: '936835f7-2d75-41d2-9001-38ed6e458328'
43
+ },
44
+ ...metric
45
+ }
46
+ },
47
+ count: {
48
+ description: 'Dataset entries count',
49
+ example: 67,
50
+ type: 'integer'
51
+ },
52
+ values: {
53
+ description: 'Dataset for this metric',
54
+ type: 'array',
55
+ items: {
56
+ type: 'object',
57
+ additionalProperties: false,
58
+ properties: values[index]
59
+ }
60
+ }
61
+ }
62
+ }))
63
+ }
64
+ })
65
+ }
66
+ }
67
+
68
+ module.exports = analyticsResponse
@@ -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
 
package/lib/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  module.exports = {
2
2
  v0: require('./v0'),
3
3
  v1: require('./v1'),
4
+ v3: require('./v3'),
4
5
  common: require('./common')
5
6
  }
@@ -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: [
@@ -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: {
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ reports: require('./reports')
3
+ }
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ transactions: require('./transactions')
3
+ }
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ overview: require('./overview')
3
+ }
@@ -0,0 +1,242 @@
1
+ const analyticsResponse = require('../../../../common/analytics_response')
2
+
3
+ const summary = {
4
+ absolute_average_transaction_cancellation_items_total: {
5
+ description: 'Absolute average total of transactions with type "sale_cancel"',
6
+ example: 2,
7
+ type: ['integer', 'null']
8
+ },
9
+ absolute_average_transaction_items_total: {
10
+ description: 'Absolute average of transactions total',
11
+ example: 2.01,
12
+ type: 'number',
13
+ multipleOf: 0.01
14
+ },
15
+ absolute_average_transaction_revenue_items_total: {
16
+ description: 'Absolute average total of transactions with types "sale" and "sale_cancel"',
17
+ example: 2.01,
18
+ type: 'number',
19
+ multipleOf: 0.01
20
+ },
21
+ absolute_average_transaction_sale_items_total: {
22
+ description: 'Absolute average total of transactions with type "sale" which never been cancelled',
23
+ example: 2.01,
24
+ type: 'number',
25
+ multipleOf: 0.01
26
+ },
27
+ average_transaction_total: {
28
+ description: 'Average transactions total',
29
+ example: 2.01,
30
+ type: 'number',
31
+ multipleOf: 0.01
32
+ },
33
+ change: {
34
+ description: 'Total change',
35
+ example: 2.01,
36
+ type: 'number',
37
+ multipleOf: 0.01
38
+ },
39
+ currency: {
40
+ description: 'Currency ISO code',
41
+ example: 'EUR',
42
+ type: 'string',
43
+ minLength: 3,
44
+ maxLength: 3
45
+ },
46
+ total: {
47
+ description: 'Total revenue',
48
+ example: 2.01,
49
+ type: 'number',
50
+ multipleOf: 0.01
51
+ },
52
+ total_cancellation_items_count: {
53
+ description: 'Total cancellations count',
54
+ example: 3,
55
+ type: 'integer'
56
+ },
57
+ total_count: {
58
+ description: 'Total transaction count',
59
+ example: 245,
60
+ type: 'integer'
61
+ },
62
+ total_revenue_items_count: {
63
+ description: 'Total revenues count',
64
+ example: 67,
65
+ type: 'integer'
66
+ },
67
+ total_sale_items_count: {
68
+ description: 'Total sales count',
69
+ example: 31,
70
+ type: 'integer'
71
+ }
72
+ }
73
+
74
+ const data = {
75
+ additional_type: {
76
+ description: 'Expense account type',
77
+ example: '',
78
+ type: ['string', 'null']
79
+ },
80
+ balance_custom_id: {
81
+ description: 'Balance custom id',
82
+ example: '2',
83
+ type: ['string', 'null']
84
+ },
85
+ branch: {
86
+ description: 'Branch UUID',
87
+ example: '936835f7-2d75-41d2-9001-38ed6e458328',
88
+ type: ['string', 'null'],
89
+ format: 'uuid'
90
+ },
91
+ branch_custom_id: {
92
+ description: 'Branch custom id',
93
+ example: '4',
94
+ type: ['string', 'null']
95
+ },
96
+ cashier_staff: {
97
+ description: 'Cashier UUID',
98
+ example: '936835f7-2d75-41d2-9001-38ed6e458328',
99
+ type: ['string', 'null'],
100
+ format: 'uuid'
101
+ },
102
+ cashier_staff_custom_id: {
103
+ description: 'Cashier custom id',
104
+ example: '234',
105
+ type: ['string', 'null']
106
+ },
107
+ change: {
108
+ description: 'The amount of change',
109
+ example: 3.34,
110
+ type: 'number',
111
+ multipleOf: 0.01
112
+ },
113
+ currency: {
114
+ description: 'Currency ISO code',
115
+ example: 'EUR',
116
+ type: 'string',
117
+ minLength: 3,
118
+ maxLength: 3
119
+ },
120
+ custom_id: {
121
+ description: 'Transaction custom id',
122
+ example: '17',
123
+ type: 'string'
124
+ },
125
+ customer: {
126
+ description: 'Customer UUID',
127
+ example: '936835f7-2d75-41d2-9001-38ed6e458328',
128
+ type: ['string', 'null'],
129
+ format: 'uuid'
130
+ },
131
+ customer_custom_id: {
132
+ description: 'Customer custom id',
133
+ example: '8328',
134
+ type: ['string', 'null']
135
+ },
136
+ customer_firstname: {
137
+ description: 'Customer first name',
138
+ example: 'Max',
139
+ type: ['string', 'null']
140
+ },
141
+ customer_lastname: {
142
+ description: 'Customer last name',
143
+ example: 'Zimmerman',
144
+ type: ['string', 'null']
145
+ },
146
+ customer_receipt: {
147
+ description: 'The customer receipt multiline text',
148
+ example: 'Bestellung: 17\n------------------------------------------\nWax in the City Berlin Charlottenburg',
149
+ type: 'string'
150
+ },
151
+ date: {
152
+ description: 'The transaction date and time in ISO 8601 format',
153
+ example: 2,
154
+ type: 'string',
155
+ format: 'date-time'
156
+ },
157
+ id: {
158
+ description: 'Transaction UUID',
159
+ example: '936835f7-2d75-41d2-9001-38ed6e458328',
160
+ type: 'string',
161
+ format: 'uuid'
162
+ },
163
+ merchant_receipt: {
164
+ description: 'The merchant receipt multiline text',
165
+ example: 'Zweitschrift,\nelektronisches Aufzeichnungssystem',
166
+ type: 'string'
167
+ },
168
+ register: {
169
+ description: 'Register UUID',
170
+ example: '936835f7-2d75-41d2-9001-38ed6e458328',
171
+ type: 'string',
172
+ format: 'uuid'
173
+ },
174
+ register_custom_id: {
175
+ description: 'Register custom id',
176
+ example: '979',
177
+ type: 'string'
178
+ },
179
+ timezone: {
180
+ description: 'Timezone code',
181
+ example: 'Europe/Berlin',
182
+ type: ['string', 'null']
183
+ },
184
+ total: {
185
+ description: 'Transaction total amount',
186
+ example: 2.01,
187
+ type: 'number',
188
+ multipleOf: 0.01
189
+ },
190
+ type: {
191
+ description: 'Transaction type',
192
+ example: 'sale',
193
+ type: 'string'
194
+ },
195
+ _external_reference_id: {
196
+ description: 'Transaction external id',
197
+ type: ['string', 'null']
198
+ },
199
+ _id: {
200
+ description: 'Transaction sequential id',
201
+ example: '64305',
202
+ type: ['string', 'null']
203
+ }
204
+ }
205
+
206
+ const meta = {
207
+ count: {
208
+ description: 'Total transactions count',
209
+ example: 315532,
210
+ type: 'integer'
211
+ }
212
+ }
213
+
214
+ const filteredMeta = {
215
+ count: {
216
+ description: 'Total transactions count under filters applied',
217
+ example: 7655,
218
+ type: 'integer'
219
+ }
220
+ }
221
+
222
+ module.exports.response = {
223
+ $id: 'https://schemas.tillhub.com/v3/analytics.reports.transactions.overview.response.schema.json',
224
+ ...analyticsResponse([{
225
+ job: { enum: ['reports_transactions_v2_overview_summary'] },
226
+ type: { enum: ['summary'] }
227
+ }, {
228
+ job: { enum: ['reports_transactions_v2_overview_data'] },
229
+ type: { enum: ['data_list'] }
230
+ }, {
231
+ job: { enum: ['reports_transactions_v2_overview_meta'] },
232
+ type: { enum: ['meta'] }
233
+ }, {
234
+ job: { enum: ['reports_transactions_v2_overview_filtered_meta'] },
235
+ type: { enum: ['filtered_meta'] }
236
+ }], [
237
+ summary,
238
+ data,
239
+ meta,
240
+ filteredMeta
241
+ ])
242
+ }
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ analytics: require('./analytics')
3
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tillhub/schemas",
3
- "version": "6.125.0",
3
+ "version": "6.128.0",
4
4
  "private": false,
5
5
  "description": "All Tillhub API OpenAPI 3 compatible JSON Schemas.",
6
6
  "main": "./lib/index.js",
@@ -0,0 +1,11 @@
1
+ const test = require('tape')
2
+ const validate = require('../../../helpers/validate-schema')
3
+ const overviewSchema = require('../../../../lib/v3/analytics/reports/transactions/overview')
4
+
5
+ test('analytics:reports:transactions:overview:v3: response schema validation', function (t) {
6
+ const { valid, error } = validate(overviewSchema.response)
7
+ t.ok(valid, 'create response schema is valid')
8
+ t.error(error, 'should not get any error')
9
+
10
+ t.end()
11
+ })