@tillhub/schemas 6.451.0 → 6.453.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.
@@ -89,19 +89,37 @@ module.exports.request = {
89
89
  minLength: 1,
90
90
  maxLength: 64
91
91
  },
92
+ as_of: {
93
+ type: 'string',
94
+ format: 'date-time',
95
+ example: '2025-12-31T22:59:59.999Z',
96
+ description:
97
+ 'ISO 8601 cut-off (inclusive). When set, Quantity Available is the latest stock-book balance at this instant per product × location. Send this or the start/end pair, not both. Omit both modes to return current stock.'
98
+ },
92
99
  start: {
93
100
  type: 'string',
94
101
  format: 'date-time',
95
102
  example: '2026-05-07T22:00:00.000Z',
96
103
  description:
97
- 'Url-safe ISO 8601 start of the reporting window. Filters stock rows by `updated_at` when set. Also used as the report `date` when `end` is omitted.'
104
+ 'Url-safe ISO 8601 start of the reporting window. Use with `end` as a pair to filter current stock rows by `updated_at`. Cannot be combined with `as_of`. Also used as the report `date` when `end` is omitted.'
98
105
  },
99
106
  end: {
100
107
  type: 'string',
101
108
  format: 'date-time',
102
109
  example: '2026-05-08T21:59:59.999Z',
103
110
  description:
104
- 'Url-safe ISO 8601 end of the reporting window. Filters stock rows by `updated_at` when set. Preferred source for the report `date` column when set.'
111
+ 'Url-safe ISO 8601 end of the reporting window. Use with `start` as a pair to filter current stock rows by `updated_at`. Cannot be combined with `as_of`. Preferred source for the report `date` column when set.'
112
+ }
113
+ },
114
+ allOf: [
115
+ {
116
+ description: 'Clients send either as_of or the start/end pair, not both.',
117
+ not: {
118
+ anyOf: [
119
+ { required: ['as_of', 'start'] },
120
+ { required: ['as_of', 'end'] }
121
+ ]
122
+ }
105
123
  }
106
- }
124
+ ]
107
125
  }
@@ -1,6 +1,9 @@
1
1
  const base = require('../product_groups/base')
2
2
  const { oneOf } = require('../../helpers/payload-or-null')
3
3
 
4
+ const DEPRECATION_NOTICE =
5
+ 'Service Categories v0 are deprecated, use v1 schemas instead'
6
+
4
7
  const request = {
5
8
  ...base.request,
6
9
  properties: {
@@ -21,10 +24,13 @@ const request = {
21
24
  default: false
22
25
  }
23
26
  },
24
- required: ['name']
27
+ required: ['name'],
28
+ deprecated: true,
29
+ description: DEPRECATION_NOTICE
25
30
  }
26
31
 
27
32
  module.exports = {
33
+ DEPRECATION_NOTICE,
28
34
  request,
29
35
  response: {
30
36
  ...request,
@@ -37,6 +43,8 @@ module.exports = {
37
43
  example: '05297f58-3408-44d0-8bf4-125d4e86c08a'
38
44
  },
39
45
  ...request.properties
40
- }
46
+ },
47
+ deprecated: true,
48
+ description: DEPRECATION_NOTICE
41
49
  }
42
50
  }
@@ -1,8 +1,10 @@
1
- const { response } = require('./base')
1
+ const { response, DEPRECATION_NOTICE } = require('./base')
2
2
  const commonResponse = require('../../common/response')
3
3
 
4
4
  module.exports = {
5
5
  $id: 'https://schemas.tillhub.com/v0/service_categories.create.response.schema.json',
6
6
  $schema: 'http://json-schema.org/draft-07/schema#',
7
- ...commonResponse({ resultItems: response })
7
+ ...commonResponse({ resultItems: response }),
8
+ deprecated: true,
9
+ description: DEPRECATION_NOTICE
8
10
  }
@@ -1,8 +1,10 @@
1
- const { response } = require('./base')
1
+ const { response, DEPRECATION_NOTICE } = require('./base')
2
2
  const commonResponse = require('../../common/response')
3
3
 
4
4
  module.exports = {
5
5
  $id: 'https://schemas.tillhub.com/v0/service_categories.update.response.schema.json',
6
6
  $schema: 'http://json-schema.org/draft-07/schema#',
7
- ...commonResponse({ resultItems: response })
7
+ ...commonResponse({ resultItems: response }),
8
+ deprecated: true,
9
+ description: DEPRECATION_NOTICE
8
10
  }
@@ -1,4 +1,5 @@
1
1
  const base = require('../products/create')
2
+ const { DEPRECATION_NOTICE } = require('./deprecation')
2
3
  const { oneOf } = require('../../helpers/payload-or-null')
3
4
 
4
5
  module.exports = {
@@ -44,6 +45,8 @@ module.exports = {
44
45
  }
45
46
  },
46
47
  required: ['name', 'duration', 'linked_product'],
48
+ deprecated: true,
49
+ description: DEPRECATION_NOTICE,
47
50
  $id: 'https://schemas.tillhub.com/v0/services.create.request.schema.json',
48
51
  $schema: 'http://json-schema.org/draft-07/schema#'
49
52
  }
@@ -1,4 +1,5 @@
1
1
  const request = require('./create.request')
2
+ const { DEPRECATION_NOTICE } = require('./deprecation')
2
3
  const commonResponse = require('../../common/response')
3
4
 
4
5
  const response = {
@@ -18,5 +19,7 @@ const response = {
18
19
  module.exports = {
19
20
  $id: 'https://schemas.tillhub.com/v0/services.create.response.schema.json',
20
21
  $schema: 'http://json-schema.org/draft-07/schema#',
21
- ...commonResponse({ resultItems: response })
22
+ ...commonResponse({ resultItems: response }),
23
+ deprecated: true,
24
+ description: DEPRECATION_NOTICE
22
25
  }
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ DEPRECATION_NOTICE: 'Services v0 are deprecated, use v1 schemas instead'
3
+ }
@@ -1,4 +1,5 @@
1
1
  const base = require('../products/update')
2
+ const { DEPRECATION_NOTICE } = require('./deprecation')
2
3
  const { oneOf } = require('../../helpers/payload-or-null')
3
4
 
4
5
  module.exports = {
@@ -43,6 +44,8 @@ module.exports = {
43
44
  }
44
45
  },
45
46
  required: [],
47
+ deprecated: true,
48
+ description: DEPRECATION_NOTICE,
46
49
  $id: 'https://schemas.tillhub.com/v0/services.update.request.schema.json',
47
50
  $schema: 'http://json-schema.org/draft-07/schema#'
48
51
  }
@@ -1,4 +1,5 @@
1
1
  const request = require('./update.request')
2
+ const { DEPRECATION_NOTICE } = require('./deprecation')
2
3
  const commonResponse = require('../../common/response')
3
4
 
4
5
  const response = {
@@ -18,5 +19,7 @@ const response = {
18
19
  module.exports = {
19
20
  $id: 'https://schemas.tillhub.com/v0/services.update.response.schema.json',
20
21
  $schema: 'http://json-schema.org/draft-07/schema#',
21
- ...commonResponse({ resultItems: response })
22
+ ...commonResponse({ resultItems: response }),
23
+ deprecated: true,
24
+ description: DEPRECATION_NOTICE
22
25
  }
@@ -135,20 +135,21 @@ module.exports = {
135
135
  format: 'date-time'
136
136
  },
137
137
  system: {
138
- oneOf: [
139
- {
140
- type: 'array',
141
- minItems: 1,
142
- items: {
143
- type: 'string',
144
- format: 'uuid'
145
- }
146
- },
147
- {
148
- type: 'string',
149
- format: 'uuid'
150
- }
151
- ]
138
+ type: 'string',
139
+ format: 'uuid'
140
+ },
141
+ voucher_system: {
142
+ type: 'string',
143
+ format: 'uuid'
144
+ },
145
+ systems: {
146
+ type: 'array',
147
+ minItems: 1,
148
+ maxItems: 50,
149
+ items: {
150
+ type: 'string',
151
+ format: 'uuid'
152
+ }
152
153
  },
153
154
  location: {
154
155
  oneOf: [
@@ -161,6 +161,107 @@ module.exports = oneOf({
161
161
  }
162
162
  }
163
163
  },
164
+ opening_hours_exceptions: {
165
+ description: 'Additive Open or Closed exceptions over a date range, optionally limited to selected weekdays. Closed is full day only. 0 = Monday … 6 = Sunday.',
166
+ type: 'array',
167
+ items: {
168
+ type: 'object',
169
+ additionalProperties: false,
170
+ required: ['type', 'start_date', 'end_date'],
171
+ properties: {
172
+ type: {
173
+ type: 'string',
174
+ enum: ['open', 'closed']
175
+ },
176
+ start_date: {
177
+ type: 'string',
178
+ format: 'date'
179
+ },
180
+ end_date: {
181
+ type: 'string',
182
+ format: 'date'
183
+ },
184
+ weekdays: {
185
+ type: 'array',
186
+ items: {
187
+ type: 'integer',
188
+ minimum: 0,
189
+ maximum: 6
190
+ }
191
+ },
192
+ from: {
193
+ oneOf: [
194
+ { type: 'null' },
195
+ { type: 'string', pattern: '^([01]\\d|2[0-3]):[0-5]\\d$' }
196
+ ]
197
+ },
198
+ to: {
199
+ oneOf: [
200
+ { type: 'null' },
201
+ { type: 'string', pattern: '^([01]\\d|2[0-3]):[0-5]\\d$' }
202
+ ]
203
+ },
204
+ break_from: {
205
+ oneOf: [
206
+ { type: 'null' },
207
+ { type: 'string', pattern: '^([01]\\d|2[0-3]):[0-5]\\d$' }
208
+ ]
209
+ },
210
+ break_to: {
211
+ oneOf: [
212
+ { type: 'null' },
213
+ { type: 'string', pattern: '^([01]\\d|2[0-3]):[0-5]\\d$' }
214
+ ]
215
+ },
216
+ reason: {
217
+ type: 'string'
218
+ }
219
+ },
220
+ allOf: [
221
+ {
222
+ if: {
223
+ properties: {
224
+ type: { const: 'closed' }
225
+ },
226
+ required: ['type']
227
+ },
228
+ then: {
229
+ properties: {
230
+ from: { type: 'null' },
231
+ to: { type: 'null' },
232
+ break_from: { type: 'null' },
233
+ break_to: { type: 'null' }
234
+ }
235
+ }
236
+ },
237
+ {
238
+ if: {
239
+ properties: {
240
+ type: { const: 'open' }
241
+ },
242
+ required: ['type']
243
+ },
244
+ then: {
245
+ oneOf: [
246
+ {
247
+ properties: {
248
+ from: { type: 'null' },
249
+ to: { type: 'null' }
250
+ }
251
+ },
252
+ {
253
+ properties: {
254
+ from: { type: 'string' },
255
+ to: { type: 'string' }
256
+ },
257
+ required: ['from', 'to']
258
+ }
259
+ ]
260
+ }
261
+ }
262
+ ]
263
+ }
264
+ },
164
265
  appointment_reminder: {
165
266
  type: 'boolean'
166
267
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tillhub/schemas",
3
- "version": "6.451.0",
3
+ "version": "6.453.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,51 @@
1
+ const test = require('tape')
2
+ const Ajv = require('ajv')
3
+ const validate = require('../../../helpers/validate-schema')
4
+ const stocksSchema = require('../../../../lib/v0/analytics/reports/stocks')
5
+
6
+ const ajv = new Ajv()
7
+ const validateRequest = ajv.compile(stocksSchema.request)
8
+
9
+ const AS_OF = '2025-12-31T22:59:59.999Z'
10
+ const START = '2026-05-07T22:00:00.000Z'
11
+ const END = '2026-05-08T21:59:59.999Z'
12
+
13
+ test('analytics:reports:stocks:v0: request schema is valid', function (t) {
14
+ t.plan(2)
15
+ const { valid, error } = validate(stocksSchema.request)
16
+ t.ok(valid, 'request schema is valid')
17
+ t.error(error, 'should not get any error')
18
+ t.end()
19
+ })
20
+
21
+ test('analytics:reports:stocks:v0: accepts as_of without start/end', function (t) {
22
+ t.plan(1)
23
+ t.ok(validateRequest({ as_of: AS_OF }), 'as_of alone is valid')
24
+ t.end()
25
+ })
26
+
27
+ test('analytics:reports:stocks:v0: accepts the start/end pair without as_of', function (t) {
28
+ t.plan(1)
29
+ t.ok(validateRequest({ start: START, end: END }), 'start/end pair is valid')
30
+ t.end()
31
+ })
32
+
33
+ test('analytics:reports:stocks:v0: accepts omitting both date modes', function (t) {
34
+ t.plan(1)
35
+ t.ok(validateRequest({}), 'current stock without as_of or start/end is valid')
36
+ t.end()
37
+ })
38
+
39
+ test('analytics:reports:stocks:v0: rejects as_of combined with start or end', function (t) {
40
+ t.plan(3)
41
+ t.notOk(validateRequest({ as_of: AS_OF, start: START }), 'as_of + start is invalid')
42
+ t.notOk(validateRequest({ as_of: AS_OF, end: END }), 'as_of + end is invalid')
43
+ t.notOk(validateRequest({ as_of: AS_OF, start: START, end: END }), 'as_of + start/end is invalid')
44
+ t.end()
45
+ })
46
+
47
+ test('analytics:reports:stocks:v0: rejects invalid as_of', function (t) {
48
+ t.plan(1)
49
+ t.notOk(validateRequest({ as_of: 'not-a-valid-iso8601' }), 'non-ISO as_of is invalid')
50
+ t.end()
51
+ })
@@ -1,6 +1,11 @@
1
1
  const test = require('tape')
2
+ const Ajv = require('ajv')
2
3
  const validate = require('../helpers/validate-schema')
3
4
 
5
+ const ajv = new Ajv({ allErrors: true })
6
+ const updateRequest = require('../../lib/v1/configurations').update.request
7
+ const validateUpdatePayload = ajv.compile(updateRequest)
8
+
4
9
  test('Configurations: create schema validation', function (t) {
5
10
  t.plan(2)
6
11
  const createRequest = require('../../lib/v1/configurations').create.request
@@ -28,3 +33,111 @@ test('Configurations: patch schema validation', function (t) {
28
33
  t.error(error, 'should not get any error')
29
34
  t.end()
30
35
  })
36
+
37
+ test('Configurations: opening_hours_exceptions accepts Open all-day, Open hours, and Closed full-day', function (t) {
38
+ t.plan(1)
39
+ const valid = validateUpdatePayload({
40
+ reservations: {
41
+ opening_hours_exceptions: [
42
+ {
43
+ type: 'open',
44
+ start_date: '2026-12-20',
45
+ end_date: '2026-12-20',
46
+ from: null,
47
+ to: null,
48
+ reason: 'Sunday brunch all day'
49
+ },
50
+ {
51
+ type: 'open',
52
+ start_date: '2026-07-02',
53
+ end_date: '2026-07-11',
54
+ weekdays: [1, 3],
55
+ from: '10:00',
56
+ to: '22:00',
57
+ break_from: null,
58
+ break_to: null,
59
+ reason: 'Summer Tue/Thu hours'
60
+ },
61
+ {
62
+ type: 'closed',
63
+ start_date: '2026-01-01',
64
+ end_date: '2026-03-31',
65
+ weekdays: [0, 1],
66
+ from: null,
67
+ to: null,
68
+ reason: 'Winter Mon/Tue closure'
69
+ }
70
+ ]
71
+ }
72
+ })
73
+ t.ok(valid, ajv.errorsText(validateUpdatePayload.errors))
74
+ t.end()
75
+ })
76
+
77
+ test('Configurations: opening_hours_exceptions rejects Closed with specific hours', function (t) {
78
+ t.plan(1)
79
+ const valid = validateUpdatePayload({
80
+ reservations: {
81
+ opening_hours_exceptions: [
82
+ {
83
+ type: 'closed',
84
+ start_date: '2026-01-01',
85
+ end_date: '2026-01-01',
86
+ from: '10:00',
87
+ to: '18:00'
88
+ }
89
+ ]
90
+ }
91
+ })
92
+ t.notOk(valid, 'Closed exceptions must be full day (from/to null)')
93
+ t.end()
94
+ })
95
+
96
+ test('Configurations: opening_hours_exceptions rejects mixed Open from/to', function (t) {
97
+ t.plan(1)
98
+ const valid = validateUpdatePayload({
99
+ reservations: {
100
+ opening_hours_exceptions: [
101
+ {
102
+ type: 'open',
103
+ start_date: '2026-12-20',
104
+ end_date: '2026-12-20',
105
+ from: '10:00',
106
+ to: null
107
+ }
108
+ ]
109
+ }
110
+ })
111
+ t.notOk(valid, 'Open from/to must both be null or both be set')
112
+ t.end()
113
+ })
114
+
115
+ test('Configurations: opening_hours_exceptions rejects invalid HH:mm times', function (t) {
116
+ t.plan(1)
117
+ const valid = validateUpdatePayload({
118
+ reservations: {
119
+ opening_hours_exceptions: [
120
+ {
121
+ type: 'open',
122
+ start_date: '2026-12-20',
123
+ end_date: '2026-12-20',
124
+ from: '25:00',
125
+ to: '26:00'
126
+ }
127
+ ]
128
+ }
129
+ })
130
+ t.notOk(valid, 'Open from/to must match HH:mm')
131
+ t.end()
132
+ })
133
+
134
+ test('Configurations: payloads without opening_hours_exceptions remain valid', function (t) {
135
+ t.plan(1)
136
+ const valid = validateUpdatePayload({
137
+ reservations: {
138
+ opening_hours: []
139
+ }
140
+ })
141
+ t.ok(valid, ajv.errorsText(validateUpdatePayload.errors))
142
+ t.end()
143
+ })