@tillhub/schemas 6.118.1 → 6.119.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 +7 -0
- package/lib/common/response.js +1 -1
- package/lib/v0/audits/index.js +3 -0
- package/lib/v0/audits/logs/base.js +81 -0
- package/lib/v0/audits/logs/index.js +3 -0
- package/lib/v0/audits/logs/read.js +30 -0
- package/lib/v0/index.js +1 -0
- package/package.json +1 -1
- package/test/audits/logs/logs.spec.js +11 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [6.119.0](https://github.com/tillhub/schemas/compare/v6.118.1...v6.119.0) (2022-02-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **audits:** add audit logs response schema #API-1331 ([#668](https://github.com/tillhub/schemas/issues/668)) ([057c73e](https://github.com/tillhub/schemas/commit/057c73e)), closes [#API-1331](https://github.com/tillhub/schemas/issues/API-1331) [#API-1331](https://github.com/tillhub/schemas/issues/API-1331)
|
|
7
|
+
|
|
1
8
|
## [6.118.1](https://github.com/tillhub/schemas/compare/v6.118.0...v6.118.1) (2022-02-14)
|
|
2
9
|
|
|
3
10
|
|
package/lib/common/response.js
CHANGED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const { oneOf } = require('../../../helpers/payload-or-null')
|
|
2
|
+
|
|
3
|
+
const changeEntry = {
|
|
4
|
+
type: 'object',
|
|
5
|
+
additionalProperties: false,
|
|
6
|
+
properties: {
|
|
7
|
+
op: {
|
|
8
|
+
description: 'Operation type',
|
|
9
|
+
type: 'string',
|
|
10
|
+
enum: [
|
|
11
|
+
'add',
|
|
12
|
+
'replace',
|
|
13
|
+
'remove'
|
|
14
|
+
]
|
|
15
|
+
},
|
|
16
|
+
path: {
|
|
17
|
+
description: 'Changed property path (with dot as separator)',
|
|
18
|
+
type: 'string',
|
|
19
|
+
example: 'images.0.url'
|
|
20
|
+
},
|
|
21
|
+
value: {
|
|
22
|
+
description: 'Changed value',
|
|
23
|
+
type: 'string',
|
|
24
|
+
example: 'This is it'
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = {
|
|
30
|
+
type: {
|
|
31
|
+
description: 'Log type (entity type and action type)',
|
|
32
|
+
type: 'string',
|
|
33
|
+
example: 'product.update'
|
|
34
|
+
},
|
|
35
|
+
old: oneOf({
|
|
36
|
+
description: 'Old data',
|
|
37
|
+
type: 'object',
|
|
38
|
+
example: {}
|
|
39
|
+
}),
|
|
40
|
+
new: oneOf({
|
|
41
|
+
description: 'New data',
|
|
42
|
+
type: 'object',
|
|
43
|
+
example: {
|
|
44
|
+
id: '0f91b67b-b1eb-4aba-827a-3a83ff967c5e',
|
|
45
|
+
name: 'Foo bar'
|
|
46
|
+
}
|
|
47
|
+
}),
|
|
48
|
+
change: oneOf({
|
|
49
|
+
description: 'Changes between old and new',
|
|
50
|
+
type: 'array',
|
|
51
|
+
items: changeEntry
|
|
52
|
+
}),
|
|
53
|
+
description: oneOf({
|
|
54
|
+
description: 'Description',
|
|
55
|
+
type: 'string',
|
|
56
|
+
example: 'Login attempt from service account'
|
|
57
|
+
}),
|
|
58
|
+
issuer: oneOf({
|
|
59
|
+
description: 'Issuer data',
|
|
60
|
+
type: 'object',
|
|
61
|
+
properties: {
|
|
62
|
+
sub_user: {
|
|
63
|
+
description: 'Sub-user (person authorized under organization account) UUID',
|
|
64
|
+
type: 'string',
|
|
65
|
+
format: 'uuid',
|
|
66
|
+
example: '8ddb94bf-98cf-4832-9833-c118ebf04675'
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}),
|
|
70
|
+
metadata: oneOf({
|
|
71
|
+
description: 'Metadata',
|
|
72
|
+
type: 'object',
|
|
73
|
+
properties: {
|
|
74
|
+
user_agent: {
|
|
75
|
+
description: 'User-agent data',
|
|
76
|
+
type: 'string',
|
|
77
|
+
example: 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.99 Safari/537.36'
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
})
|
|
81
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const commonBase = { ...require('../../../common/base') }
|
|
2
|
+
const commonResponse = require('../../../common/response')
|
|
3
|
+
const { oneOf } = require('../../../helpers/payload-or-null')
|
|
4
|
+
|
|
5
|
+
const base = require('./base')
|
|
6
|
+
|
|
7
|
+
// Logs are read-only
|
|
8
|
+
delete commonBase.updated_at
|
|
9
|
+
|
|
10
|
+
module.exports.response = {
|
|
11
|
+
$id: 'https://schemas.tillhub.com/v0/audits.logs.read.response.schema.json',
|
|
12
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
13
|
+
additionalProperties: false,
|
|
14
|
+
...commonResponse({
|
|
15
|
+
resultItems: {
|
|
16
|
+
type: 'object',
|
|
17
|
+
required: ['id', 'created_at', 'insert_id', 'type'],
|
|
18
|
+
additionalProperties: false,
|
|
19
|
+
properties: {
|
|
20
|
+
...commonBase,
|
|
21
|
+
insert_id: oneOf({
|
|
22
|
+
description: 'Sequential counter',
|
|
23
|
+
type: 'integer',
|
|
24
|
+
example: 16259
|
|
25
|
+
}),
|
|
26
|
+
...base
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}, { hasCursor: true })
|
|
30
|
+
}
|
package/lib/v0/index.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
const test = require('tape')
|
|
2
|
+
const validate = require('../../helpers/validate-schema')
|
|
3
|
+
|
|
4
|
+
test('Audits:logs: read.response schema validation', function (t) {
|
|
5
|
+
t.plan(2)
|
|
6
|
+
const readResponse = require('../../../lib/v0/audits/logs').read.response
|
|
7
|
+
const { valid, error } = validate(readResponse)
|
|
8
|
+
t.ok(valid, 'create schema is valid')
|
|
9
|
+
t.error(error, 'should not get any error')
|
|
10
|
+
t.end()
|
|
11
|
+
})
|