@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2013-2025 Ghost Foundation
3
+ Copyright (c) 2013-2026 Ghost Foundation
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -93,4 +93,4 @@ Follow the instructions for the top-level repo.
93
93
 
94
94
  # Copyright & License
95
95
 
96
- Copyright (c) 2013-2025 Ghost Foundation - Released under the [MIT license](LICENSE).
96
+ Copyright (c) 2013-2026 Ghost Foundation - Released under the [MIT license](LICENSE).
@@ -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
+ }
@@ -1,4 +1,5 @@
1
1
  module.exports = [
2
+ 'comment_bans-add',
2
3
  'images-upload',
3
4
  'media-upload',
4
5
  'labels-add',
@@ -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
  }
@@ -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
- defFunc.definition = {
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
  };
@@ -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
- formats: {
11
- 'json-string': (data) => {
12
- try {
13
- JSON.parse(data);
14
- return true;
15
- } catch (e) {
16
- return false;
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 dataPath = _.get(validation, 'errors[0].dataPath');
43
+ const instancePath = _.get(validation, 'errors[0].instancePath');
39
44
 
40
- if (dataPath) {
41
- key = dataPath.split('.').pop();
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.5.13",
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 --all --reporter text --reporter cobertura mocha './test/**/*.test.js'",
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": "10.1.3",
26
+ "c8": "11.0.0",
27
27
  "mocha": "11.7.5",
28
28
  "should": "13.2.3",
29
- "sinon": "21.0.0"
29
+ "sinon": "21.0.1"
30
30
  },
31
31
  "dependencies": {
32
- "@tryghost/errors": "1.3.8",
33
- "ajv": "^6.12.6",
34
- "lodash": "^4.17.11"
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": "a97d783ddb64ae80592ec03468b221a4ec37948a"
37
+ "gitHead": "2c937c80e98d9bad4458e1c2e9d6f6b138bd308e"
37
38
  }