@tillhub/schemas 6.121.0 → 6.124.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.
@@ -0,0 +1,29 @@
1
+ const baseObject = require('../../common/base')
2
+ const commonResponse = require('../../common/response')
3
+ const base = require('./base')
4
+
5
+ module.exports = {
6
+ request: {
7
+ $id: 'https://schemas.tillhub.com/v1/carts.patch.request.schema.json',
8
+ $schema: 'http://json-schema.org/draft-07/schema#',
9
+ type: 'object',
10
+ additionalProperties: false,
11
+ required: [
12
+ ],
13
+ properties: base
14
+ },
15
+ response: {
16
+ $id: 'https://schemas.tillhub.com/v1/carts.patch.response.schema.json',
17
+ $schema: 'http://json-schema.org/draft-07/schema#',
18
+ ...commonResponse({
19
+ resultItems: {
20
+ type: 'object',
21
+ additionalProperties: false,
22
+ properties: {
23
+ ...baseObject(),
24
+ ...base
25
+ }
26
+ }
27
+ })
28
+ }
29
+ }
@@ -0,0 +1,54 @@
1
+ const baseObject = require('../../common/base')
2
+ const commonResponse = require('../../common/response')
3
+ const { oneOf } = require('../../helpers/payload-or-null')
4
+ const base = require('./base')
5
+
6
+ const override = {
7
+ customer: {
8
+ description: 'Customer ID or customer data (in case when "embed=[customer]" presented query parameters) cart belongs to',
9
+ example: '55ec2da5-f9a4-4868-8f00-65ae0804a9d3',
10
+ ...oneOf([{
11
+ type: 'string',
12
+ format: 'uuid'
13
+ }, {
14
+ type: 'object'
15
+ }])
16
+ }
17
+ }
18
+
19
+ const extended = { ...base, ...override }
20
+
21
+ module.exports = {
22
+ all: {
23
+ response: {
24
+ $id: 'https://schemas.tillhub.com/v1/carts.read.all.response.schema.json',
25
+ $schema: 'http://json-schema.org/draft-07/schema#',
26
+ ...commonResponse({
27
+ resultItems: {
28
+ type: 'object',
29
+ additionalProperties: false,
30
+ properties: {
31
+ ...baseObject(),
32
+ ...extended
33
+ }
34
+ }
35
+ })
36
+ }
37
+ },
38
+ one: {
39
+ response: {
40
+ $id: 'https://schemas.tillhub.com/v1/carts.read.one.response.schema.json',
41
+ $schema: 'http://json-schema.org/draft-07/schema#',
42
+ ...commonResponse({
43
+ resultItems: {
44
+ type: 'object',
45
+ additionalProperties: false,
46
+ properties: {
47
+ ...baseObject(),
48
+ ...extended
49
+ }
50
+ }
51
+ })
52
+ }
53
+ }
54
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tillhub/schemas",
3
- "version": "6.121.0",
3
+ "version": "6.124.0",
4
4
  "private": false,
5
5
  "description": "All Tillhub API OpenAPI 3 compatible JSON Schemas.",
6
6
  "main": "./lib/index.js",
@@ -1,11 +1,51 @@
1
1
  const test = require('tape')
2
2
  const validate = require('../helpers/validate-schema')
3
+ const cartsSchema = require('../../lib/v1/carts')
4
+
5
+ test('Carts:v1: create schema validation', function (t) {
6
+ {
7
+ const { valid, error } = validate(cartsSchema.create.request)
8
+ t.ok(valid, 'create request schema is valid')
9
+ t.error(error, 'should not get any error')
10
+ }
11
+
12
+ {
13
+ const { valid, error } = validate(cartsSchema.create.response)
14
+ t.ok(valid, 'create response schema is valid')
15
+ t.error(error, 'should not get any error')
16
+ }
17
+
18
+ t.end()
19
+ })
20
+
21
+ test('Carts:v1: read schema validation', function (t) {
22
+ {
23
+ const { valid, error } = validate(cartsSchema.read.all.response)
24
+ t.ok(valid, 'read.all response schema is valid')
25
+ t.error(error, 'should not get any error')
26
+ }
27
+
28
+ {
29
+ const { valid, error } = validate(cartsSchema.read.one.response)
30
+ t.ok(valid, 'read.one response schema is valid')
31
+ t.error(error, 'should not get any error')
32
+ }
33
+
34
+ t.end()
35
+ })
36
+
37
+ test('Carts:v1: patch schema validation', function (t) {
38
+ {
39
+ const { valid, error } = validate(cartsSchema.patch.request)
40
+ t.ok(valid, 'patch request schema is valid')
41
+ t.error(error, 'should not get any error')
42
+ }
43
+
44
+ {
45
+ const { valid, error } = validate(cartsSchema.patch.response)
46
+ t.ok(valid, 'patch response schema is valid')
47
+ t.error(error, 'should not get any error')
48
+ }
3
49
 
4
- test('Carts: create schema validation', function (t) {
5
- t.plan(2)
6
- const createRequest = require('../../lib/v1/carts').create.request
7
- const { valid, error } = validate(createRequest)
8
- t.ok(valid, 'create schema is valid')
9
- t.error(error, 'should not get any error')
10
50
  t.end()
11
51
  })
@@ -1,268 +0,0 @@
1
- const items = require('./items').create
2
-
3
- module.exports = {
4
- $id: 'https://schemas.tillhub.com/v1/carts.create.request.schema.json',
5
- $schema: 'http://json-schema.org/draft-07/schema#',
6
- type: 'object',
7
- additionalProperties: false,
8
- required: [
9
- 'items'
10
- ],
11
- properties: {
12
- date: {
13
- oneOf: [
14
- {
15
- type: 'string',
16
- format: 'date-time'
17
- },
18
- {
19
- type: 'null'
20
- }
21
- ]
22
- },
23
- done_at: {
24
- description: 'Date when this cart was used in a transaction (currently). If date is not null, this cart must not be used.',
25
- oneOf: [
26
- {
27
- type: 'string',
28
- format: 'date-time'
29
- },
30
- {
31
- type: 'null'
32
- }
33
- ]
34
- },
35
- branch: {
36
- oneOf: [
37
- {
38
- type: 'string',
39
- format: 'uuid'
40
- },
41
- {
42
- type: 'null'
43
- }
44
- ]
45
- },
46
- register: {
47
- oneOf: [
48
- {
49
- type: 'string',
50
- format: 'uuid'
51
- },
52
- {
53
- type: 'null'
54
- }
55
- ]
56
- },
57
- cashier_staff: {
58
- oneOf: [
59
- {
60
- type: 'string',
61
- format: 'uuid'
62
- },
63
- {
64
- type: 'null'
65
- }
66
- ]
67
- },
68
- temporary_staff: {
69
- description: 'Staff who was lending permissions temporarily (in case that \'cashier_staff\' did not have that permission)',
70
- oneOf: [
71
- {
72
- type: 'string',
73
- format: 'uuid'
74
- },
75
- {
76
- type: 'null'
77
- }
78
- ]
79
- },
80
- currency: {
81
- oneOf: [
82
- {
83
- type: 'string',
84
- minLength: 3,
85
- maxLength: 3
86
- },
87
- {
88
- type: 'null'
89
- }
90
- ]
91
- },
92
- custom_id: {
93
- description: 'User defined (human readable) identifier for the cart, e.g. counting number 1, 2, 3 ...',
94
- oneOf: [
95
- {
96
- type: 'string',
97
- example: '17',
98
- maxLength: 128
99
- },
100
- {
101
- type: 'null'
102
- }
103
- ]
104
- },
105
- client_id: {
106
- description: 'Producer side unique identifier to resolve downstream mapping targets, e.g. GUID or UUID',
107
- oneOf: [
108
- {
109
- type: 'string',
110
- example: '00060968000420200624004214945',
111
- minLength: 12,
112
- maxLength: 64
113
- },
114
- {
115
- type: 'null'
116
- }
117
- ]
118
- },
119
- cart_id: {
120
- oneOf: [
121
- {
122
- type: 'string',
123
- maxLength: 128
124
- },
125
- {
126
- type: 'null'
127
- }
128
- ]
129
- },
130
- external_reference_id: {
131
- oneOf: [
132
- {
133
- type: 'string',
134
- maxLength: 128
135
- },
136
- {
137
- type: 'null'
138
- }
139
- ]
140
- },
141
- lps: {
142
- description: 'Lean Payment System: If TRUE the client application will process this cart with minimal validation and without forced property fetching. Use on at your own risk.',
143
- oneOf: [
144
- {
145
- type: 'boolean'
146
- },
147
- {
148
- type: 'null'
149
- }
150
- ]
151
- },
152
- instant_checkout: {
153
- description: 'If TRUE this cart will be checked out immediately and thus landing on the payment screen.',
154
- oneOf: [
155
- {
156
- type: 'boolean'
157
- },
158
- {
159
- type: 'null'
160
- }
161
- ]
162
- },
163
- immutable: {
164
- description: 'If TRUE this cart will not be editable, thus a user can not remove nor add new items.',
165
- oneOf: [
166
- {
167
- type: 'boolean'
168
- },
169
- {
170
- type: 'null'
171
- }
172
- ]
173
- },
174
- customer: {
175
- oneOf: [
176
- {
177
- type: 'string',
178
- format: 'uuid'
179
- },
180
- {
181
- type: 'null'
182
- }
183
- ]
184
- },
185
- customer_name: {
186
- oneOf: [
187
- {
188
- type: 'string',
189
- maxLength: 64
190
- },
191
- {
192
- type: 'null'
193
- }
194
- ]
195
- },
196
- customer_description: {
197
- oneOf: [
198
- {
199
- type: 'string',
200
- maxLength: 128
201
- },
202
- {
203
- type: 'null'
204
- }
205
- ]
206
- },
207
- customer_number: {
208
- oneOf: [
209
- {
210
- type: 'string',
211
- maxLength: 128
212
- },
213
- {
214
- type: 'null'
215
- }
216
- ]
217
- },
218
- name: {
219
- oneOf: [
220
- {
221
- type: 'string',
222
- maxLength: 128
223
- },
224
- {
225
- type: 'null'
226
- }
227
- ]
228
- },
229
- description: {
230
- oneOf: [
231
- {
232
- type: 'string',
233
- maxLength: 512
234
- },
235
- {
236
- type: 'null'
237
- }
238
- ]
239
- },
240
- comments: {
241
- oneOf: [
242
- {
243
- type: 'string',
244
- maxLength: 4096
245
- },
246
- {
247
- type: 'null'
248
- }
249
- ]
250
- },
251
- items,
252
- metadata: {
253
- type: 'object'
254
- },
255
- opened_at: {
256
- description: 'Date when this cart was opened. If date is not null, this cart must not be used.',
257
- oneOf: [
258
- {
259
- type: 'string',
260
- format: 'date-time'
261
- },
262
- {
263
- type: 'null'
264
- }
265
- ]
266
- }
267
- }
268
- }
@@ -1,259 +0,0 @@
1
- const items = require('./items').create
2
- module.exports = {
3
- $id: 'https://schemas.tillhub.com/v1/carts.patch.request.schema.json',
4
- $schema: 'http://json-schema.org/draft-07/schema#',
5
- type: 'object',
6
- additionalProperties: false,
7
- required: [
8
- ],
9
- properties: {
10
- date: {
11
- oneOf: [
12
- {
13
- type: 'string',
14
- format: 'date-time'
15
- },
16
- {
17
- type: 'null'
18
- }
19
- ]
20
- },
21
- done_at: {
22
- oneOf: [
23
- {
24
- type: 'string',
25
- format: 'date-time'
26
- },
27
- {
28
- type: 'null'
29
- }
30
- ]
31
- },
32
- branch: {
33
- oneOf: [
34
- {
35
- type: 'string',
36
- format: 'uuid'
37
- },
38
- {
39
- type: 'null'
40
- }
41
- ]
42
- },
43
- register: {
44
- oneOf: [
45
- {
46
- type: 'string',
47
- format: 'uuid'
48
- },
49
- {
50
- type: 'null'
51
- }
52
- ]
53
- },
54
- cashier_staff: {
55
- oneOf: [
56
- {
57
- type: 'string',
58
- format: 'uuid'
59
- },
60
- {
61
- type: 'null'
62
- }
63
- ]
64
- },
65
- temporary_staff: {
66
- oneOf: [
67
- {
68
- type: 'string',
69
- format: 'uuid'
70
- },
71
- {
72
- type: 'null'
73
- }
74
- ]
75
- },
76
- currency: {
77
- oneOf: [
78
- {
79
- type: 'string',
80
- minLength: 3,
81
- maxLength: 3
82
- },
83
- {
84
- type: 'null'
85
- }
86
- ]
87
- },
88
- custom_id: {
89
- oneOf: [
90
- {
91
- type: 'string',
92
- maxLength: 128
93
- },
94
- {
95
- type: 'null'
96
- }
97
- ]
98
- },
99
- client_id: {
100
- oneOf: [
101
- {
102
- type: 'string',
103
- minLength: 12,
104
- maxLength: 64
105
- },
106
- {
107
- type: 'null'
108
- }
109
- ]
110
- },
111
- cart_id: {
112
- oneOf: [
113
- {
114
- type: 'string',
115
- maxLength: 128
116
- },
117
- {
118
- type: 'null'
119
- }
120
- ]
121
- },
122
- external_reference_id: {
123
- oneOf: [
124
- {
125
- type: 'string',
126
- maxLength: 128
127
- },
128
- {
129
- type: 'null'
130
- }
131
- ]
132
- },
133
- lps: {
134
- description: 'Lean Payment System: If TRUE the client application will process this cart with minimal validation and without forced property fetching. Use on at your own risk.',
135
- oneOf: [
136
- {
137
- type: 'boolean'
138
- },
139
- {
140
- type: 'null'
141
- }
142
- ]
143
- },
144
- instant_checkout: {
145
- description: 'If TRUE this cart will be checked out immediately and thus landing on the payment screen.',
146
- oneOf: [
147
- {
148
- type: 'boolean'
149
- },
150
- {
151
- type: 'null'
152
- }
153
- ]
154
- },
155
- immutable: {
156
- description: 'If TRUE this cart will not be editable, thus a user can not remove nor add new items.',
157
- oneOf: [
158
- {
159
- type: 'boolean'
160
- },
161
- {
162
- type: 'null'
163
- }
164
- ]
165
- },
166
- customer: {
167
- oneOf: [
168
- {
169
- type: 'string',
170
- format: 'uuid'
171
- },
172
- {
173
- type: 'null'
174
- }
175
- ]
176
- },
177
- customer_name: {
178
- oneOf: [
179
- {
180
- type: 'string',
181
- maxLength: 64
182
- },
183
- {
184
- type: 'null'
185
- }
186
- ]
187
- },
188
- customer_description: {
189
- oneOf: [
190
- {
191
- type: 'string',
192
- maxLength: 128
193
- },
194
- {
195
- type: 'null'
196
- }
197
- ]
198
- },
199
- customer_number: {
200
- oneOf: [
201
- {
202
- type: 'string',
203
- maxLength: 128
204
- },
205
- {
206
- type: 'null'
207
- }
208
- ]
209
- },
210
- name: {
211
- oneOf: [
212
- {
213
- type: 'string',
214
- maxLength: 128
215
- },
216
- {
217
- type: 'null'
218
- }
219
- ]
220
- },
221
- description: {
222
- oneOf: [
223
- {
224
- type: 'string',
225
- maxLength: 512
226
- },
227
- {
228
- type: 'null'
229
- }
230
- ]
231
- },
232
- comments: {
233
- oneOf: [
234
- {
235
- type: 'string',
236
- maxLength: 4096
237
- },
238
- {
239
- type: 'null'
240
- }
241
- ]
242
- },
243
- items,
244
- metadata: {
245
- type: 'object'
246
- },
247
- opened_at: {
248
- oneOf: [
249
- {
250
- type: 'string',
251
- format: 'date-time'
252
- },
253
- {
254
- type: 'null'
255
- }
256
- ]
257
- }
258
- }
259
- }