@tryghost/admin-api-schema 4.6.1 → 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/utils/is-lowercase-keyword.js +3 -4
- package/lib/utils/json-schema.js +17 -12
- package/package.json +8 -7
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -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
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
|
}
|