@tryghost/admin-api 1.9.1 → 1.11.1
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/lib/index.js +10 -1
- package/package.json +2 -2
package/lib/index.js
CHANGED
|
@@ -3,6 +3,9 @@ const FormData = require('form-data');
|
|
|
3
3
|
const fs = require('fs');
|
|
4
4
|
const token = require('./token');
|
|
5
5
|
|
|
6
|
+
const packageInfo = require('../package.json');
|
|
7
|
+
const packageVersion = packageInfo.version;
|
|
8
|
+
|
|
6
9
|
// NOTE: bump this default when Ghost v5 is released
|
|
7
10
|
const defaultAcceptVersionHeader = 'v4.0';
|
|
8
11
|
const supportedVersions = ['v2', 'v3', 'v4', 'v5', 'canary'];
|
|
@@ -54,6 +57,7 @@ module.exports = function GhostAdminAPI(options) {
|
|
|
54
57
|
data,
|
|
55
58
|
headers,
|
|
56
59
|
maxContentLength: Infinity,
|
|
60
|
+
maxBodyLength: Infinity,
|
|
57
61
|
paramsSerializer(parameters) {
|
|
58
62
|
return Object.keys(parameters).reduce((parts, key) => {
|
|
59
63
|
const val = encodeURIComponent([].concat(parameters[key]).join(','));
|
|
@@ -138,6 +142,10 @@ module.exports = function GhostAdminAPI(options) {
|
|
|
138
142
|
'users'
|
|
139
143
|
];
|
|
140
144
|
|
|
145
|
+
if (typeof config.version === 'string' && config.version.startsWith('v2')) {
|
|
146
|
+
resources.push('subscribers');
|
|
147
|
+
}
|
|
148
|
+
|
|
141
149
|
const api = resources.reduce((apiObject, resourceType) => {
|
|
142
150
|
function add(data, queryParams = {}) {
|
|
143
151
|
if (!data || !Object.keys(data).length) {
|
|
@@ -413,7 +421,8 @@ module.exports = function GhostAdminAPI(options) {
|
|
|
413
421
|
authorizationHeader = `Ghost ${config.generateToken(key, audience)}`;
|
|
414
422
|
|
|
415
423
|
const ghostHeaders = {
|
|
416
|
-
Authorization: authorizationHeader
|
|
424
|
+
Authorization: authorizationHeader,
|
|
425
|
+
'User-Agent': `GhostAdminSDK/${packageVersion}`
|
|
417
426
|
};
|
|
418
427
|
|
|
419
428
|
if (config.acceptVersionHeader) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/admin-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.11.1",
|
|
4
4
|
"repository": "https://github.com/TryGhost/SDK/tree/master/packages/admin-api",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"form-data": "^4.0.0",
|
|
32
32
|
"jsonwebtoken": "^8.4.0"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "f699f18279c596be384760adccbbf90a659bd4bc"
|
|
35
35
|
}
|