@tillhub/schemas 6.125.0 → 6.126.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.126.0](https://github.com/tillhub/schemas/compare/v6.125.0...v6.126.0) (2022-03-15)
2
+
3
+
4
+ ### Features
5
+
6
+ * **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)
7
+
1
8
  # [6.125.0](https://github.com/tillhub/schemas/compare/v6.124.0...v6.125.0) (2022-03-10)
2
9
 
3
10
 
@@ -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
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
  }
@@ -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.126.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
+ })