@tryghost/admin-api-schema 4.5.13 → 4.7.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/LICENSE +1 -1
- package/README.md +1 -1
- package/lib/schemas/comment_bans-add.json +19 -0
- package/lib/schemas/comment_bans.json +24 -0
- package/lib/schemas/index.js +1 -0
- package/lib/schemas/members-edit.json +17 -0
- package/lib/schemas/members.json +17 -0
- package/lib/utils/is-lowercase-keyword.js +3 -4
- package/lib/utils/json-schema.js +17 -12
- package/package.json +9 -8
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "comment_bans.add",
|
|
4
|
+
"title": "comment_bans.add",
|
|
5
|
+
"description": "Schema for comment_bans.add",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": false,
|
|
8
|
+
"properties": {
|
|
9
|
+
"comment_bans": {
|
|
10
|
+
"type": "array",
|
|
11
|
+
"minItems": 1,
|
|
12
|
+
"maxItems": 1,
|
|
13
|
+
"items": {
|
|
14
|
+
"allOf": [{ "$ref": "comment_bans#/definitions/comment_ban" }]
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"required": ["comment_bans"]
|
|
19
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "comment_bans",
|
|
4
|
+
"title": "comment_bans",
|
|
5
|
+
"description": "Base comment_bans definitions",
|
|
6
|
+
"definitions": {
|
|
7
|
+
"comment_ban": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"additionalProperties": false,
|
|
10
|
+
"properties": {
|
|
11
|
+
"reason": {
|
|
12
|
+
"type": "string",
|
|
13
|
+
"minLength": 1,
|
|
14
|
+
"maxLength": 2000
|
|
15
|
+
},
|
|
16
|
+
"expires_at": {
|
|
17
|
+
"type": ["string", "null"],
|
|
18
|
+
"format": "date-time"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"required": ["reason"]
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
package/lib/schemas/index.js
CHANGED
|
@@ -50,6 +50,23 @@
|
|
|
50
50
|
},
|
|
51
51
|
"labels": {
|
|
52
52
|
"$ref": "members#/definitions/member-labels"
|
|
53
|
+
},
|
|
54
|
+
"can_comment": {
|
|
55
|
+
"type": "boolean"
|
|
56
|
+
},
|
|
57
|
+
"comment_ban": {
|
|
58
|
+
"oneOf": [
|
|
59
|
+
{
|
|
60
|
+
"type": "object",
|
|
61
|
+
"additionalProperties": false,
|
|
62
|
+
"properties": {
|
|
63
|
+
"reason": { "type": "string", "minLength": 1, "maxLength": 2000 },
|
|
64
|
+
"expires_at": { "type": ["string", "null"], "format": "date-time" }
|
|
65
|
+
},
|
|
66
|
+
"required": ["reason"]
|
|
67
|
+
},
|
|
68
|
+
{ "type": "null" }
|
|
69
|
+
]
|
|
53
70
|
}
|
|
54
71
|
}
|
|
55
72
|
}
|
package/lib/schemas/members.json
CHANGED
|
@@ -47,6 +47,23 @@
|
|
|
47
47
|
},
|
|
48
48
|
"newsletters": {
|
|
49
49
|
"$ref": "#/definitions/member-newsletters"
|
|
50
|
+
},
|
|
51
|
+
"can_comment": {
|
|
52
|
+
"type": "boolean"
|
|
53
|
+
},
|
|
54
|
+
"comment_ban": {
|
|
55
|
+
"oneOf": [
|
|
56
|
+
{
|
|
57
|
+
"type": "object",
|
|
58
|
+
"additionalProperties": false,
|
|
59
|
+
"properties": {
|
|
60
|
+
"reason": { "type": "string", "minLength": 1, "maxLength": 2000 },
|
|
61
|
+
"expires_at": { "type": ["string", "null"], "format": "date-time" }
|
|
62
|
+
},
|
|
63
|
+
"required": ["reason"]
|
|
64
|
+
},
|
|
65
|
+
{ "type": "null" }
|
|
66
|
+
]
|
|
50
67
|
}
|
|
51
68
|
}
|
|
52
69
|
},
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
module.exports = function defFunc(ajv) {
|
|
2
|
-
|
|
2
|
+
ajv.addKeyword({
|
|
3
|
+
keyword: 'isLowercase',
|
|
3
4
|
errors: false,
|
|
4
5
|
validate: function (schema, data) {
|
|
5
6
|
if (data) {
|
|
@@ -8,8 +9,6 @@ module.exports = function defFunc(ajv) {
|
|
|
8
9
|
|
|
9
10
|
return true;
|
|
10
11
|
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
ajv.addKeyword('isLowercase', defFunc.definition);
|
|
12
|
+
});
|
|
14
13
|
return ajv;
|
|
15
14
|
};
|
package/lib/utils/json-schema.js
CHANGED
|
@@ -1,20 +1,25 @@
|
|
|
1
1
|
const _ = require('lodash');
|
|
2
2
|
const Ajv = require('ajv');
|
|
3
|
+
const addFormats = require('ajv-formats');
|
|
3
4
|
const isLowercaseKeyword = require('./is-lowercase-keyword');
|
|
4
5
|
const errors = require('@tryghost/errors');
|
|
5
6
|
|
|
6
7
|
const ajv = new Ajv({
|
|
7
8
|
allErrors: true,
|
|
8
9
|
useDefaults: true,
|
|
9
|
-
removeAdditional: true
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
removeAdditional: true
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
addFormats(ajv);
|
|
14
|
+
|
|
15
|
+
ajv.addFormat('json-string', {
|
|
16
|
+
type: 'string',
|
|
17
|
+
validate: (data) => {
|
|
18
|
+
try {
|
|
19
|
+
JSON.parse(data);
|
|
20
|
+
return true;
|
|
21
|
+
} catch (e) {
|
|
22
|
+
return false;
|
|
18
23
|
}
|
|
19
24
|
}
|
|
20
25
|
});
|
|
@@ -35,10 +40,10 @@ const validate = (schema, definition, data) => {
|
|
|
35
40
|
|
|
36
41
|
if (validation.errors) {
|
|
37
42
|
let key;
|
|
38
|
-
const
|
|
43
|
+
const instancePath = _.get(validation, 'errors[0].instancePath');
|
|
39
44
|
|
|
40
|
-
if (
|
|
41
|
-
key =
|
|
45
|
+
if (instancePath) {
|
|
46
|
+
key = instancePath.split('/').pop();
|
|
42
47
|
} else {
|
|
43
48
|
key = schema.$id.split('.')[0];
|
|
44
49
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/admin-api-schema",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/TryGhost/SDK.git",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"main": "index.js",
|
|
12
12
|
"scripts": {
|
|
13
13
|
"dev": "echo \"Implement me!\"",
|
|
14
|
-
"test": "NODE_ENV=testing c8 --
|
|
14
|
+
"test": "NODE_ENV=testing c8 --reporter text --reporter cobertura mocha './test/**/*.test.js'",
|
|
15
15
|
"lint": "eslint . --ext .js --cache",
|
|
16
16
|
"posttest": "yarn lint"
|
|
17
17
|
},
|
|
@@ -23,15 +23,16 @@
|
|
|
23
23
|
"access": "public"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"c8": "
|
|
26
|
+
"c8": "11.0.0",
|
|
27
27
|
"mocha": "11.7.5",
|
|
28
28
|
"should": "13.2.3",
|
|
29
|
-
"sinon": "21.0.
|
|
29
|
+
"sinon": "21.0.1"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@tryghost/errors": "
|
|
33
|
-
"ajv": "
|
|
34
|
-
"
|
|
32
|
+
"@tryghost/errors": "2.2.1",
|
|
33
|
+
"ajv": "8.18.0",
|
|
34
|
+
"ajv-formats": "3.0.1",
|
|
35
|
+
"lodash": "4.17.23"
|
|
35
36
|
},
|
|
36
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "2c937c80e98d9bad4458e1c2e9d6f6b138bd308e"
|
|
37
38
|
}
|