@tillhub/schemas 6.230.0 → 6.232.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,17 @@
1
+ # [6.232.0](https://github.com/tillhub/schemas/compare/v6.231.0...v6.232.0) (2023-07-20)
2
+
3
+
4
+ ### Features
5
+
6
+ * **products:** configurations ([fdba281](https://github.com/tillhub/schemas/commit/fdba281))
7
+
8
+ # [6.231.0](https://github.com/tillhub/schemas/compare/v6.230.0...v6.231.0) (2023-07-20)
9
+
10
+
11
+ ### Features
12
+
13
+ * **service_categories:** add service_categories.create ([#829](https://github.com/tillhub/schemas/issues/829)) ([fc3e117](https://github.com/tillhub/schemas/commit/fc3e117))
14
+
1
15
  # [6.230.0](https://github.com/tillhub/schemas/compare/v6.229.0...v6.230.0) (2023-07-14)
2
16
 
3
17
 
package/lib/v0/index.js CHANGED
@@ -74,5 +74,6 @@ module.exports.table_layouts = require('./table_layouts')
74
74
  module.exports.product_addons = require('./product_addons')
75
75
  module.exports.product_addon_groups = require('./product_addon_groups')
76
76
  module.exports.configurations = require('./configurations')
77
+ module.exports.service_categories = require('./service_categories')
77
78
 
78
79
  // hygen:injection - Please, don't delete this line: when running the cli for schema resources the new routes will be automatically added here.
@@ -0,0 +1,41 @@
1
+ const base = require('../product_groups/base')
2
+
3
+ const request = {
4
+ ...base.request,
5
+ properties: {
6
+ ...base.request.properties,
7
+ description: {
8
+ description: 'A description of the service category',
9
+ type: 'string',
10
+ example: 'Haircuts for men'
11
+ },
12
+ active: {
13
+ description: 'Soft disable or enable this service category.',
14
+ type: 'boolean',
15
+ default: true
16
+ },
17
+ deleted: {
18
+ description: 'Soft delete this service category.',
19
+ type: 'boolean',
20
+ default: false
21
+ }
22
+ },
23
+ required: ['name']
24
+ }
25
+
26
+ module.exports = {
27
+ request,
28
+ response: {
29
+ ...request,
30
+ required: [],
31
+ properties: {
32
+ id: {
33
+ description: 'The service category ID',
34
+ type: 'string',
35
+ format: 'uuid',
36
+ example: '05297f58-3408-44d0-8bf4-125d4e86c08a'
37
+ },
38
+ ...request.properties
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,7 @@
1
+ const { request } = require('./base')
2
+
3
+ module.exports = {
4
+ $id: 'https://schemas.tillhub.com/v0/service_categories.create.request.schema.json',
5
+ $schema: 'http://json-schema.org/draft-07/schema#',
6
+ ...request
7
+ }
@@ -0,0 +1,8 @@
1
+ const { response } = require('./base')
2
+ const commonResponse = require('../../common/response')
3
+
4
+ module.exports = {
5
+ $id: 'https://schemas.tillhub.com/v0/service_categories.create.response.schema.json',
6
+ $schema: 'http://json-schema.org/draft-07/schema#',
7
+ ...commonResponse({ resultItems: response })
8
+ }
@@ -0,0 +1,4 @@
1
+ module.exports.create = {
2
+ request: require('./create.request'),
3
+ response: require('./create.response')
4
+ }
@@ -1,4 +1,6 @@
1
+ const { oneOf } = require('../../../helpers/payload-or-null')
1
2
  const { stripIndents } = require('common-tags')
3
+
2
4
  module.exports = {
3
5
  description: 'Defines various product behaviours.',
4
6
  default: {
@@ -12,6 +14,59 @@ module.exports = {
12
14
  type: 'object',
13
15
  additionalProperties: true,
14
16
  properties: {
17
+ external_rewards: oneOf({
18
+ type: 'object',
19
+ description: stripIndents`
20
+ Can grant external rewards when added to a cart.
21
+
22
+ NOTE: Should be used sparsely for special campign products that require barcode scanning as sort of campaign activator.
23
+ Should be used for products that are bound to specific branch groups.
24
+ These products will be currently visible to anyone as there is no dedicated type planned (Summer 2023).
25
+ `,
26
+ additionalProperties: true,
27
+ properties: {
28
+ coop: oneOf({
29
+ type: 'object',
30
+ description: 'Can grant Coop rewards when added to a cart.',
31
+ properties: {
32
+ campaign: oneOf({
33
+ type: 'object',
34
+ description: 'Can grant Coop campaign rewards when part of an active cart.',
35
+ properties: {
36
+ name: {
37
+ description: 'Name of the campaign',
38
+ type: 'string',
39
+ example: 'Super Summer',
40
+ minLength: 2,
41
+ maxLength: 24
42
+ },
43
+ multiplier: {
44
+ type: 'integer',
45
+ description: 'Superpoint multiplier on cart total',
46
+ minimum: 1,
47
+ maximum: 100,
48
+ default: 1
49
+ },
50
+ date_start: oneOf({
51
+ type: 'string',
52
+ format: 'date-time',
53
+ example: '2023-08-04 12:00:21.165+00',
54
+ description: 'Start date of the campaign',
55
+ default: null // fallback: distant past
56
+ }),
57
+ date_end: oneOf({
58
+ type: 'string',
59
+ format: 'date-time',
60
+ example: '2023-10-23 16:51:29.143+00',
61
+ description: 'End date of the campaign',
62
+ default: null // fallback: distant future
63
+ })
64
+ }
65
+ })
66
+ }
67
+ })
68
+ }
69
+ }),
15
70
  allow_zero_prices: {
16
71
  deprecated: true,
17
72
  description: 'Allow adding this product to a cart if it has no price.',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tillhub/schemas",
3
- "version": "6.230.0",
3
+ "version": "6.232.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,20 @@
1
+ const test = require('tape')
2
+ const validate = require('../../helpers/validate-schema')
3
+
4
+ test('Service Categories V0: create request schema validation', t => {
5
+ t.plan(2)
6
+ const createRequest = require('../../../lib/v0/service_categories').create.request
7
+ const { valid, error } = validate(createRequest)
8
+ t.ok(valid, 'create request schema is valid')
9
+ t.error(error, 'should not get any error')
10
+ t.end()
11
+ })
12
+
13
+ test('Service Categories V0: create response schema validation', t => {
14
+ t.plan(2)
15
+ const createResponse = require('../../../lib/v0/service_categories').create.response
16
+ const { valid, error } = validate(createResponse)
17
+ t.ok(valid, 'create response schema is valid')
18
+ t.error(error, 'should not get any error')
19
+ t.end()
20
+ })