@tryghost/content-api 1.11.11 → 1.11.12
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/cjs/content-api.js +5 -5
- package/es/content-api.js +5 -5
- package/package.json +5 -5
- package/umd/content-api.min.js +1 -1
package/cjs/content-api.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var axios = require('axios');
|
|
4
4
|
|
|
5
5
|
var name$1 = "@tryghost/content-api";
|
|
6
|
-
var version = "1.11.
|
|
6
|
+
var version = "1.11.12";
|
|
7
7
|
var repository = "https://github.com/TryGhost/SDK/tree/master/packages/content-api";
|
|
8
8
|
var author = "Ghost Foundation";
|
|
9
9
|
var license = "MIT";
|
|
@@ -32,12 +32,12 @@ var publishConfig = {
|
|
|
32
32
|
access: "public"
|
|
33
33
|
};
|
|
34
34
|
var devDependencies = {
|
|
35
|
-
"@babel/core": "7.22.
|
|
35
|
+
"@babel/core": "7.22.5",
|
|
36
36
|
"@babel/polyfill": "7.12.1",
|
|
37
|
-
"@babel/preset-env": "7.22.
|
|
37
|
+
"@babel/preset-env": "7.22.5",
|
|
38
38
|
"@rollup/plugin-json": "6.0.0",
|
|
39
39
|
c8: "7.13.0",
|
|
40
|
-
"core-js": "3.
|
|
40
|
+
"core-js": "3.31.0",
|
|
41
41
|
"eslint-plugin-ghost": "2.16.0",
|
|
42
42
|
mocha: "10.2.0",
|
|
43
43
|
rollup: "2.79.1",
|
|
@@ -53,7 +53,7 @@ var devDependencies = {
|
|
|
53
53
|
var dependencies = {
|
|
54
54
|
axios: "^0.27.0"
|
|
55
55
|
};
|
|
56
|
-
var gitHead = "
|
|
56
|
+
var gitHead = "40c8c9cd51bc0f625695f63158c8f180c5ac4f51";
|
|
57
57
|
var packageInfo = {
|
|
58
58
|
name: name$1,
|
|
59
59
|
version: version,
|
package/es/content-api.js
CHANGED
|
@@ -2018,7 +2018,7 @@ axios_1.default = default_1;
|
|
|
2018
2018
|
var axios = axios_1;
|
|
2019
2019
|
|
|
2020
2020
|
var name$1 = "@tryghost/content-api";
|
|
2021
|
-
var version = "1.11.
|
|
2021
|
+
var version = "1.11.12";
|
|
2022
2022
|
var repository = "https://github.com/TryGhost/SDK/tree/master/packages/content-api";
|
|
2023
2023
|
var author = "Ghost Foundation";
|
|
2024
2024
|
var license = "MIT";
|
|
@@ -2047,12 +2047,12 @@ var publishConfig = {
|
|
|
2047
2047
|
access: "public"
|
|
2048
2048
|
};
|
|
2049
2049
|
var devDependencies = {
|
|
2050
|
-
"@babel/core": "7.22.
|
|
2050
|
+
"@babel/core": "7.22.5",
|
|
2051
2051
|
"@babel/polyfill": "7.12.1",
|
|
2052
|
-
"@babel/preset-env": "7.22.
|
|
2052
|
+
"@babel/preset-env": "7.22.5",
|
|
2053
2053
|
"@rollup/plugin-json": "6.0.0",
|
|
2054
2054
|
c8: "7.13.0",
|
|
2055
|
-
"core-js": "3.
|
|
2055
|
+
"core-js": "3.31.0",
|
|
2056
2056
|
"eslint-plugin-ghost": "2.16.0",
|
|
2057
2057
|
mocha: "10.2.0",
|
|
2058
2058
|
rollup: "2.79.1",
|
|
@@ -2068,7 +2068,7 @@ var devDependencies = {
|
|
|
2068
2068
|
var dependencies = {
|
|
2069
2069
|
axios: "^0.27.0"
|
|
2070
2070
|
};
|
|
2071
|
-
var gitHead = "
|
|
2071
|
+
var gitHead = "40c8c9cd51bc0f625695f63158c8f180c5ac4f51";
|
|
2072
2072
|
var packageInfo = {
|
|
2073
2073
|
name: name$1,
|
|
2074
2074
|
version: version,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tryghost/content-api",
|
|
3
|
-
"version": "1.11.
|
|
3
|
+
"version": "1.11.12",
|
|
4
4
|
"repository": "https://github.com/TryGhost/SDK/tree/master/packages/content-api",
|
|
5
5
|
"author": "Ghost Foundation",
|
|
6
6
|
"license": "MIT",
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
"access": "public"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@babel/core": "7.22.
|
|
33
|
+
"@babel/core": "7.22.5",
|
|
34
34
|
"@babel/polyfill": "7.12.1",
|
|
35
|
-
"@babel/preset-env": "7.22.
|
|
35
|
+
"@babel/preset-env": "7.22.5",
|
|
36
36
|
"@rollup/plugin-json": "6.0.0",
|
|
37
37
|
"c8": "7.13.0",
|
|
38
|
-
"core-js": "3.
|
|
38
|
+
"core-js": "3.31.0",
|
|
39
39
|
"eslint-plugin-ghost": "2.16.0",
|
|
40
40
|
"mocha": "10.2.0",
|
|
41
41
|
"rollup": "2.79.1",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"axios": "^0.27.0"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "40c8c9cd51bc0f625695f63158c8f180c5ac4f51"
|
|
55
55
|
}
|
package/umd/content-api.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).GhostContentAPI=t()}(this,(function(){"use strict";var e,t=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}},r=Object.prototype.toString,n=(e=Object.create(null),function(t){var n=r.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())});function o(e){return e=e.toLowerCase(),function(t){return n(t)===e}}function i(e){return Array.isArray(e)}function s(e){return void 0===e}var a=o("ArrayBuffer");function u(e){return null!==e&&"object"==typeof e}function c(e){if("object"!==n(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var f=o("Date"),l=o("File"),d=o("Blob"),h=o("FileList");function p(e){return"[object Function]"===r.call(e)}var m=o("URLSearchParams");function g(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var v,y=(v="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return v&&e instanceof v}),E={isArray:i,isArrayBuffer:a,isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){var t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||r.call(e)===t||p(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&a(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:u,isPlainObject:c,isUndefined:s,isDate:f,isFile:l,isBlob:d,isFunction:p,isStream:function(e){return u(e)&&p(e.pipe)},isURLSearchParams:m,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:g,merge:function e(){var t={};function r(r,n){c(t[n])&&c(r)?t[n]=e(t[n],r):c(r)?t[n]=e({},r):i(r)?t[n]=r.slice():t[n]=r}for(var n=0,o=arguments.length;n<o;n++)g(arguments[n],r);return t},extend:function(e,r,n){return g(r,(function(r,o){e[o]=n&&"function"==typeof r?t(r,n):r})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,r,n){e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,r&&Object.assign(e.prototype,r)},toFlatObject:function(e,t,r){var n,o,i,s={};t=t||{};do{for(o=(n=Object.getOwnPropertyNames(e)).length;o-- >0;)s[i=n[o]]||(t[i]=e[i],s[i]=!0);e=Object.getPrototypeOf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:n,kindOfTest:o,endsWith:function(e,t,r){e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;var n=e.indexOf(t,r);return-1!==n&&n===r},toArray:function(e){if(!e)return null;var t=e.length;if(s(t))return null;for(var r=new Array(t);t-- >0;)r[t]=e[t];return r},isTypedArray:y,isFileList:h};function w(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var b=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(E.isURLSearchParams(t))n=t.toString();else{var o=[];E.forEach(t,(function(e,t){null!=e&&(E.isArray(e)?t+="[]":e=[e],E.forEach(e,(function(e){E.isDate(e)?e=e.toISOString():E.isObject(e)&&(e=JSON.stringify(e)),o.push(w(t)+"="+w(e))})))})),n=o.join("&")}if(n){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e};function O(){this.handlers=[]}O.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},O.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},O.prototype.forEach=function(e){E.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var R=O,A=function(e,t){E.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))};function j(e,t,r,n,o){Error.call(this),this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}E.inherits(j,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var S=j.prototype,C={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED"].forEach((function(e){C[e]={value:e}})),Object.defineProperties(j,C),Object.defineProperty(S,"isAxiosError",{value:!0}),j.from=function(e,t,r,n,o,i){var s=Object.create(S);return E.toFlatObject(e,s,(function(e){return e!==Error.prototype})),j.call(s,e.message,t,r,n,o),s.name=e.name,i&&Object.assign(s,i),s};var T=j,N={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var _=function(e,t){t=t||new FormData;var r=[];function n(e){return null===e?"":E.isDate(e)?e.toISOString():E.isArrayBuffer(e)||E.isTypedArray(e)?"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}return function e(o,i){if(E.isPlainObject(o)||E.isArray(o)){if(-1!==r.indexOf(o))throw Error("Circular reference detected in "+i);r.push(o),E.forEach(o,(function(r,o){if(!E.isUndefined(r)){var s,a=i?i+"."+o:o;if(r&&!i&&"object"==typeof r)if(E.endsWith(o,"{}"))r=JSON.stringify(r);else if(E.endsWith(o,"[]")&&(s=E.toArray(r)))return void s.forEach((function(e){!E.isUndefined(e)&&t.append(a,n(e))}));e(r,a)}})),r.pop()}else t.append(i,n(o))}(e),t},x=E.isStandardBrowserEnv()?{write:function(e,t,r,n,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),E.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),E.isString(n)&&s.push("path="+n),E.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},P=function(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t},U=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],D=E.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function n(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=n(window.location.href),function(t){var r=E.isString(t)?n(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0};function B(e){T.call(this,null==e?"canceled":e,T.ERR_CANCELED),this.name="CanceledError"}E.inherits(B,T,{__CANCEL__:!0});var k=B,$=function(e){return new Promise((function(t,r){var n,o=e.data,i=e.headers,s=e.responseType;function a(){e.cancelToken&&e.cancelToken.unsubscribe(n),e.signal&&e.signal.removeEventListener("abort",n)}E.isFormData(o)&&E.isStandardBrowserEnv()&&delete i["Content-Type"];var u=new XMLHttpRequest;if(e.auth){var c=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.Authorization="Basic "+btoa(c+":"+f)}var l=P(e.baseURL,e.url);function d(){if(u){var n,o,i,c,f,l="getAllResponseHeaders"in u?(n=u.getAllResponseHeaders(),f={},n?(E.forEach(n.split("\n"),(function(e){if(c=e.indexOf(":"),o=E.trim(e.substr(0,c)).toLowerCase(),i=E.trim(e.substr(c+1)),o){if(f[o]&&U.indexOf(o)>=0)return;f[o]="set-cookie"===o?(f[o]?f[o]:[]).concat([i]):f[o]?f[o]+", "+i:i}})),f):f):null;!function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new T("Request failed with status code "+r.status,[T.ERR_BAD_REQUEST,T.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}((function(e){t(e),a()}),(function(e){r(e),a()}),{data:s&&"text"!==s&&"json"!==s?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:l,config:e,request:u}),u=null}}if(u.open(e.method.toUpperCase(),b(l,e.params,e.paramsSerializer),!0),u.timeout=e.timeout,"onloadend"in u?u.onloadend=d:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(d)},u.onabort=function(){u&&(r(new T("Request aborted",T.ECONNABORTED,e,u)),u=null)},u.onerror=function(){r(new T("Network Error",T.ERR_NETWORK,e,u,u)),u=null},u.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",n=e.transitional||N;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(new T(t,n.clarifyTimeoutError?T.ETIMEDOUT:T.ECONNABORTED,e,u)),u=null},E.isStandardBrowserEnv()){var h=(e.withCredentials||D(l))&&e.xsrfCookieName?x.read(e.xsrfCookieName):void 0;h&&(i[e.xsrfHeaderName]=h)}"setRequestHeader"in u&&E.forEach(i,(function(e,t){void 0===o&&"content-type"===t.toLowerCase()?delete i[t]:u.setRequestHeader(t,e)})),E.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),s&&"json"!==s&&(u.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&u.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(n=function(e){u&&(r(!e||e&&e.type?new k:e),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(n),e.signal&&(e.signal.aborted?n():e.signal.addEventListener("abort",n))),o||(o=null);var p,m=(p=/^([-+\w]{1,25})(:?\/\/|:)/.exec(l))&&p[1]||"";m&&-1===["http","https","file"].indexOf(m)?r(new T("Unsupported protocol "+m+":",T.ERR_BAD_REQUEST,e)):u.send(o)}))},L={"Content-Type":"application/x-www-form-urlencoded"};function q(e,t){!E.isUndefined(e)&&E.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var F,I={transitional:N,adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(F=$),F),transformRequest:[function(e,t){if(A(t,"Accept"),A(t,"Content-Type"),E.isFormData(e)||E.isArrayBuffer(e)||E.isBuffer(e)||E.isStream(e)||E.isFile(e)||E.isBlob(e))return e;if(E.isArrayBufferView(e))return e.buffer;if(E.isURLSearchParams(e))return q(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var r,n=E.isObject(e),o=t&&t["Content-Type"];if((r=E.isFileList(e))||n&&"multipart/form-data"===o){var i=this.env&&this.env.FormData;return _(r?{"files[]":e}:e,i&&new i)}return n||"application/json"===o?(q(t,"application/json"),function(e,t,r){if(E.isString(e))try{return(t||JSON.parse)(e),E.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||I.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,o=!r&&"json"===this.responseType;if(o||n&&E.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw T.from(e,T.ERR_BAD_RESPONSE,this,null,this.response);throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:null},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};E.forEach(["delete","get","head"],(function(e){I.headers[e]={}})),E.forEach(["post","put","patch"],(function(e){I.headers[e]=E.merge(L)}));var M=I,J=function(e,t,r){var n=this||M;return E.forEach(r,(function(r){e=r.call(n,e,t)})),e},W=function(e){return!(!e||!e.__CANCEL__)};function z(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new k}var H=function(e){return z(e),e.headers=e.headers||{},e.data=J.call(e,e.data,e.headers,e.transformRequest),e.headers=E.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),E.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||M.adapter)(e).then((function(t){return z(e),t.data=J.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return W(t)||(z(e),t&&t.response&&(t.response.data=J.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},V=function(e,t){t=t||{};var r={};function n(e,t){return E.isPlainObject(e)&&E.isPlainObject(t)?E.merge(e,t):E.isPlainObject(t)?E.merge({},t):E.isArray(t)?t.slice():t}function o(r){return E.isUndefined(t[r])?E.isUndefined(e[r])?void 0:n(void 0,e[r]):n(e[r],t[r])}function i(e){if(!E.isUndefined(t[e]))return n(void 0,t[e])}function s(r){return E.isUndefined(t[r])?E.isUndefined(e[r])?void 0:n(void 0,e[r]):n(void 0,t[r])}function a(r){return r in t?n(e[r],t[r]):r in e?n(void 0,e[r]):void 0}var u={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a};return E.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=u[e]||o,n=t(e);E.isUndefined(n)&&t!==a||(r[e]=n)})),r},K="0.27.2",X=K,G={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){G[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var Q={};G.transitional=function(e,t,r){function n(e,t){return"[Axios v"+X+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,o,i){if(!1===e)throw new T(n(o," has been removed"+(t?" in "+t:"")),T.ERR_DEPRECATED);return t&&!Q[o]&&(Q[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,o,i)}};var Y={assertOptions:function(e,t,r){if("object"!=typeof e)throw new T("options must be an object",T.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(e),o=n.length;o-- >0;){var i=n[o],s=t[i];if(s){var a=e[i],u=void 0===a||s(a,i,e);if(!0!==u)throw new T("option "+i+" must be "+u,T.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new T("Unknown option "+i,T.ERR_BAD_OPTION)}},validators:G},Z=Y.validators;function ee(e){this.defaults=e,this.interceptors={request:new R,response:new R}}ee.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=V(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var r=t.transitional;void 0!==r&&Y.assertOptions(r,{silentJSONParsing:Z.transitional(Z.boolean),forcedJSONParsing:Z.transitional(Z.boolean),clarifyTimeoutError:Z.transitional(Z.boolean)},!1);var n=[],o=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,n.unshift(e.fulfilled,e.rejected))}));var i,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!o){var a=[H,void 0];for(Array.prototype.unshift.apply(a,n),a=a.concat(s),i=Promise.resolve(t);a.length;)i=i.then(a.shift(),a.shift());return i}for(var u=t;n.length;){var c=n.shift(),f=n.shift();try{u=c(u)}catch(e){f(e);break}}try{i=H(u)}catch(e){return Promise.reject(e)}for(;s.length;)i=i.then(s.shift(),s.shift());return i},ee.prototype.getUri=function(e){e=V(this.defaults,e);var t=P(e.baseURL,e.url);return b(t,e.params,e.paramsSerializer)},E.forEach(["delete","get","head","options"],(function(e){ee.prototype[e]=function(t,r){return this.request(V(r||{},{method:e,url:t,data:(r||{}).data}))}})),E.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,o){return this.request(V(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}ee.prototype[e]=t(),ee.prototype[e+"Form"]=t(!0)}));var te=ee;function re(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;this.promise.then((function(e){if(r._listeners){var t,n=r._listeners.length;for(t=0;t<n;t++)r._listeners[t](e);r._listeners=null}})),this.promise.then=function(e){var t,n=new Promise((function(e){r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e){r.reason||(r.reason=new k(e),t(r.reason))}))}re.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},re.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},re.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},re.source=function(){var e;return{token:new re((function(t){e=t})),cancel:e}};var ne=re;var oe=function e(r){var n=new te(r),o=t(te.prototype.request,n);return E.extend(o,te.prototype,n),E.extend(o,n),o.create=function(t){return e(V(r,t))},o}(M);oe.Axios=te,oe.CanceledError=k,oe.CancelToken=ne,oe.isCancel=W,oe.VERSION=K,oe.toFormData=_,oe.AxiosError=T,oe.Cancel=oe.CanceledError,oe.all=function(e){return Promise.all(e)},oe.spread=function(e){return function(t){return e.apply(null,t)}},oe.isAxiosError=function(e){return E.isObject(e)&&!0===e.isAxiosError};var ie=oe,se=oe;ie.default=se;var ae=ie;const ue="1.11.11",ce="v5.0",fe=["v2","v3","v4","v5","canary"],le="@tryghost/content-api",de=e=>{let t;if("v5"===e||void 0===e||e.match(/^v5\.\d+/))t="/content/";else if(e.match(/^v\d+\.\d+/)){t=`/${/^(v\d+)\.\d+/.exec(e)[1]}/content/`}else t=`/${e}/content/`;return t},he=e=>{let{url:t,method:r,params:n,headers:o}=e;return ae[r](t,{params:n,paramsSerializer:e=>Object.keys(e).reduce(((t,r)=>{const n=encodeURIComponent([].concat(e[r]).join(","));return t.concat(`${r}=${n}`)}),[]).join("&"),headers:o})};return function e(t){let r,{url:n,key:o,host:i,version:s,userAgent:a,ghostPath:u="ghost",makeRequest:c=he}=t;if(i&&(console.warn(`${le}: The 'host' parameter is deprecated, please use 'url' instead`),n||(n=i)),this instanceof e)return e({url:n,key:o,version:s,userAgent:a,ghostPath:u,makeRequest:c});if(void 0===s)throw new Error(`${le} Config Missing: 'version' is required. E.g. ${fe.join(",")}`);if("boolean"==typeof s)!0===s&&(r=ce),s=void 0;else{if(s&&!fe.includes(s)&&!s.match(/^v\d+\.\d+/))throw new Error(`${le} Config Invalid: 'version' ${s} is not supported`);"canary"===s?(console.warn(`${le}: The 'version' parameter has a deprecated format 'canary', please use 'v{major}.{minor}' format instead`),r=ce):s.match(/^v\d+$/)?(console.warn(`${le}: The 'version' parameter has a deprecated format 'v{major}', please use 'v{major}.{minor}' format instead`),r=`${s}.0`):r=s}if(!n)throw new Error(`${le} Config Missing: 'url' is required. E.g. 'https://site.com'`);if(!/https?:\/\//.test(n))throw new Error(`${le} Config Invalid: 'url' ${n} requires a protocol. E.g. 'https://site.com'`);if(n.endsWith("/"))throw new Error(`${le} Config Invalid: 'url' ${n} must not have a trailing slash. E.g. 'https://site.com'`);if(u.endsWith("/")||u.startsWith("/"))throw new Error(`${le} Config Invalid: 'ghostPath' ${u} must not have a leading or trailing slash. E.g. 'ghost'`);if(o&&!/[0-9a-f]{26}/.test(o))throw new Error(`${le} Config Invalid: 'key' ${o} must have 26 hex characters`);void 0===a&&(a=false);const f=["posts","authors","tags","pages","settings","tiers","newsletters","offers"].reduce(((e,t)=>Object.assign(e,{[t]:{read:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;if(!e||!e.id&&!e.slug)return Promise.reject(new Error(`${le} read requires an id or slug.`));const o=Object.assign({},e,r);return l(t,o,e.id||`slug/${e.slug}`,n)},browse:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;return l(t,e,null,r)}}})),{});return delete f.settings.read,delete f.tiers.read,delete f.newsletters.read,delete f.offers.browse,f;function l(e,t,i){let f=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(!f&&!o)return Promise.reject(new Error(`${le} Config Missing: 'key' is required.`));delete t.id;const l=f?{Authorization:`GhostMembers ${f}`}:{};a&&(l["User-Agent"]="boolean"==typeof a?`GhostContentSDK/${ue}`:a),r&&(l["Accept-Version"]=r),t=Object.assign({key:o},t);const d=`${n}/${u}/api${de(s)}${e}/${i?i+"/":""}`;return c({url:d,method:"get",params:t,headers:l}).then((t=>Array.isArray(t.data[e])?1!==t.data[e].length||t.data.meta?Object.assign(t.data[e],{meta:t.data.meta}):t.data[e][0]:t.data[e])).catch((e=>{if(e.response&&e.response.data&&e.response.data.errors){const t=e.response.data.errors[0],r=new Error(t.message),n=Object.keys(t);throw r.name=t.type,n.forEach((e=>{r[e]=t[e]})),r.response=e.response,r.request=e.request,r.config=e.config,r}throw e}))}}}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).GhostContentAPI=t()}(this,(function(){"use strict";var e,t=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}},r=Object.prototype.toString,n=(e=Object.create(null),function(t){var n=r.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())});function o(e){return e=e.toLowerCase(),function(t){return n(t)===e}}function i(e){return Array.isArray(e)}function s(e){return void 0===e}var a=o("ArrayBuffer");function u(e){return null!==e&&"object"==typeof e}function c(e){if("object"!==n(e))return!1;var t=Object.getPrototypeOf(e);return null===t||t===Object.prototype}var f=o("Date"),l=o("File"),d=o("Blob"),h=o("FileList");function p(e){return"[object Function]"===r.call(e)}var m=o("URLSearchParams");function g(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(null,e[o],o,e)}var v,y=(v="undefined"!=typeof Uint8Array&&Object.getPrototypeOf(Uint8Array),function(e){return v&&e instanceof v}),E={isArray:i,isArrayBuffer:a,isBuffer:function(e){return null!==e&&!s(e)&&null!==e.constructor&&!s(e.constructor)&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)},isFormData:function(e){var t="[object FormData]";return e&&("function"==typeof FormData&&e instanceof FormData||r.call(e)===t||p(e.toString)&&e.toString()===t)},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&a(e.buffer)},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:u,isPlainObject:c,isUndefined:s,isDate:f,isFile:l,isBlob:d,isFunction:p,isStream:function(e){return u(e)&&p(e.pipe)},isURLSearchParams:m,isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:g,merge:function e(){var t={};function r(r,n){c(t[n])&&c(r)?t[n]=e(t[n],r):c(r)?t[n]=e({},r):i(r)?t[n]=r.slice():t[n]=r}for(var n=0,o=arguments.length;n<o;n++)g(arguments[n],r);return t},extend:function(e,r,n){return g(r,(function(r,o){e[o]=n&&"function"==typeof r?t(r,n):r})),e},trim:function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,r,n){e.prototype=Object.create(t.prototype,n),e.prototype.constructor=e,r&&Object.assign(e.prototype,r)},toFlatObject:function(e,t,r){var n,o,i,s={};t=t||{};do{for(o=(n=Object.getOwnPropertyNames(e)).length;o-- >0;)s[i=n[o]]||(t[i]=e[i],s[i]=!0);e=Object.getPrototypeOf(e)}while(e&&(!r||r(e,t))&&e!==Object.prototype);return t},kindOf:n,kindOfTest:o,endsWith:function(e,t,r){e=String(e),(void 0===r||r>e.length)&&(r=e.length),r-=t.length;var n=e.indexOf(t,r);return-1!==n&&n===r},toArray:function(e){if(!e)return null;var t=e.length;if(s(t))return null;for(var r=new Array(t);t-- >0;)r[t]=e[t];return r},isTypedArray:y,isFileList:h};function w(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}var b=function(e,t,r){if(!t)return e;var n;if(r)n=r(t);else if(E.isURLSearchParams(t))n=t.toString();else{var o=[];E.forEach(t,(function(e,t){null!=e&&(E.isArray(e)?t+="[]":e=[e],E.forEach(e,(function(e){E.isDate(e)?e=e.toISOString():E.isObject(e)&&(e=JSON.stringify(e)),o.push(w(t)+"="+w(e))})))})),n=o.join("&")}if(n){var i=e.indexOf("#");-1!==i&&(e=e.slice(0,i)),e+=(-1===e.indexOf("?")?"?":"&")+n}return e};function O(){this.handlers=[]}O.prototype.use=function(e,t,r){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!r&&r.synchronous,runWhen:r?r.runWhen:null}),this.handlers.length-1},O.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},O.prototype.forEach=function(e){E.forEach(this.handlers,(function(t){null!==t&&e(t)}))};var R=O,A=function(e,t){E.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))};function j(e,t,r,n,o){Error.call(this),this.message=e,this.name="AxiosError",t&&(this.code=t),r&&(this.config=r),n&&(this.request=n),o&&(this.response=o)}E.inherits(j,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var S=j.prototype,C={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED"].forEach((function(e){C[e]={value:e}})),Object.defineProperties(j,C),Object.defineProperty(S,"isAxiosError",{value:!0}),j.from=function(e,t,r,n,o,i){var s=Object.create(S);return E.toFlatObject(e,s,(function(e){return e!==Error.prototype})),j.call(s,e.message,t,r,n,o),s.name=e.name,i&&Object.assign(s,i),s};var T=j,N={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1};var _=function(e,t){t=t||new FormData;var r=[];function n(e){return null===e?"":E.isDate(e)?e.toISOString():E.isArrayBuffer(e)||E.isTypedArray(e)?"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}return function e(o,i){if(E.isPlainObject(o)||E.isArray(o)){if(-1!==r.indexOf(o))throw Error("Circular reference detected in "+i);r.push(o),E.forEach(o,(function(r,o){if(!E.isUndefined(r)){var s,a=i?i+"."+o:o;if(r&&!i&&"object"==typeof r)if(E.endsWith(o,"{}"))r=JSON.stringify(r);else if(E.endsWith(o,"[]")&&(s=E.toArray(r)))return void s.forEach((function(e){!E.isUndefined(e)&&t.append(a,n(e))}));e(r,a)}})),r.pop()}else t.append(i,n(o))}(e),t},x=E.isStandardBrowserEnv()?{write:function(e,t,r,n,o,i){var s=[];s.push(e+"="+encodeURIComponent(t)),E.isNumber(r)&&s.push("expires="+new Date(r).toGMTString()),E.isString(n)&&s.push("path="+n),E.isString(o)&&s.push("domain="+o),!0===i&&s.push("secure"),document.cookie=s.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}},P=function(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t},U=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"],D=E.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function n(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:"/"===r.pathname.charAt(0)?r.pathname:"/"+r.pathname}}return e=n(window.location.href),function(t){var r=E.isString(t)?n(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0};function B(e){T.call(this,null==e?"canceled":e,T.ERR_CANCELED),this.name="CanceledError"}E.inherits(B,T,{__CANCEL__:!0});var k=B,$=function(e){return new Promise((function(t,r){var n,o=e.data,i=e.headers,s=e.responseType;function a(){e.cancelToken&&e.cancelToken.unsubscribe(n),e.signal&&e.signal.removeEventListener("abort",n)}E.isFormData(o)&&E.isStandardBrowserEnv()&&delete i["Content-Type"];var u=new XMLHttpRequest;if(e.auth){var c=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.Authorization="Basic "+btoa(c+":"+f)}var l=P(e.baseURL,e.url);function d(){if(u){var n,o,i,c,f,l="getAllResponseHeaders"in u?(n=u.getAllResponseHeaders(),f={},n?(E.forEach(n.split("\n"),(function(e){if(c=e.indexOf(":"),o=E.trim(e.substr(0,c)).toLowerCase(),i=E.trim(e.substr(c+1)),o){if(f[o]&&U.indexOf(o)>=0)return;f[o]="set-cookie"===o?(f[o]?f[o]:[]).concat([i]):f[o]?f[o]+", "+i:i}})),f):f):null;!function(e,t,r){var n=r.config.validateStatus;r.status&&n&&!n(r.status)?t(new T("Request failed with status code "+r.status,[T.ERR_BAD_REQUEST,T.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r)):e(r)}((function(e){t(e),a()}),(function(e){r(e),a()}),{data:s&&"text"!==s&&"json"!==s?u.response:u.responseText,status:u.status,statusText:u.statusText,headers:l,config:e,request:u}),u=null}}if(u.open(e.method.toUpperCase(),b(l,e.params,e.paramsSerializer),!0),u.timeout=e.timeout,"onloadend"in u?u.onloadend=d:u.onreadystatechange=function(){u&&4===u.readyState&&(0!==u.status||u.responseURL&&0===u.responseURL.indexOf("file:"))&&setTimeout(d)},u.onabort=function(){u&&(r(new T("Request aborted",T.ECONNABORTED,e,u)),u=null)},u.onerror=function(){r(new T("Network Error",T.ERR_NETWORK,e,u,u)),u=null},u.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",n=e.transitional||N;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),r(new T(t,n.clarifyTimeoutError?T.ETIMEDOUT:T.ECONNABORTED,e,u)),u=null},E.isStandardBrowserEnv()){var h=(e.withCredentials||D(l))&&e.xsrfCookieName?x.read(e.xsrfCookieName):void 0;h&&(i[e.xsrfHeaderName]=h)}"setRequestHeader"in u&&E.forEach(i,(function(e,t){void 0===o&&"content-type"===t.toLowerCase()?delete i[t]:u.setRequestHeader(t,e)})),E.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),s&&"json"!==s&&(u.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&u.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&u.upload&&u.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(n=function(e){u&&(r(!e||e&&e.type?new k:e),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(n),e.signal&&(e.signal.aborted?n():e.signal.addEventListener("abort",n))),o||(o=null);var p,m=(p=/^([-+\w]{1,25})(:?\/\/|:)/.exec(l))&&p[1]||"";m&&-1===["http","https","file"].indexOf(m)?r(new T("Unsupported protocol "+m+":",T.ERR_BAD_REQUEST,e)):u.send(o)}))},L={"Content-Type":"application/x-www-form-urlencoded"};function q(e,t){!E.isUndefined(e)&&E.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var F,I={transitional:N,adapter:(("undefined"!=typeof XMLHttpRequest||"undefined"!=typeof process&&"[object process]"===Object.prototype.toString.call(process))&&(F=$),F),transformRequest:[function(e,t){if(A(t,"Accept"),A(t,"Content-Type"),E.isFormData(e)||E.isArrayBuffer(e)||E.isBuffer(e)||E.isStream(e)||E.isFile(e)||E.isBlob(e))return e;if(E.isArrayBufferView(e))return e.buffer;if(E.isURLSearchParams(e))return q(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString();var r,n=E.isObject(e),o=t&&t["Content-Type"];if((r=E.isFileList(e))||n&&"multipart/form-data"===o){var i=this.env&&this.env.FormData;return _(r?{"files[]":e}:e,i&&new i)}return n||"application/json"===o?(q(t,"application/json"),function(e,t,r){if(E.isString(e))try{return(t||JSON.parse)(e),E.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(r||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||I.transitional,r=t&&t.silentJSONParsing,n=t&&t.forcedJSONParsing,o=!r&&"json"===this.responseType;if(o||n&&E.isString(e)&&e.length)try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw T.from(e,T.ERR_BAD_RESPONSE,this,null,this.response);throw e}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:null},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};E.forEach(["delete","get","head"],(function(e){I.headers[e]={}})),E.forEach(["post","put","patch"],(function(e){I.headers[e]=E.merge(L)}));var M=I,J=function(e,t,r){var n=this||M;return E.forEach(r,(function(r){e=r.call(n,e,t)})),e},W=function(e){return!(!e||!e.__CANCEL__)};function z(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new k}var H=function(e){return z(e),e.headers=e.headers||{},e.data=J.call(e,e.data,e.headers,e.transformRequest),e.headers=E.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),E.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||M.adapter)(e).then((function(t){return z(e),t.data=J.call(e,t.data,t.headers,e.transformResponse),t}),(function(t){return W(t)||(z(e),t&&t.response&&(t.response.data=J.call(e,t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))},V=function(e,t){t=t||{};var r={};function n(e,t){return E.isPlainObject(e)&&E.isPlainObject(t)?E.merge(e,t):E.isPlainObject(t)?E.merge({},t):E.isArray(t)?t.slice():t}function o(r){return E.isUndefined(t[r])?E.isUndefined(e[r])?void 0:n(void 0,e[r]):n(e[r],t[r])}function i(e){if(!E.isUndefined(t[e]))return n(void 0,t[e])}function s(r){return E.isUndefined(t[r])?E.isUndefined(e[r])?void 0:n(void 0,e[r]):n(void 0,t[r])}function a(r){return r in t?n(e[r],t[r]):r in e?n(void 0,e[r]):void 0}var u={url:i,method:i,data:i,baseURL:s,transformRequest:s,transformResponse:s,paramsSerializer:s,timeout:s,timeoutMessage:s,withCredentials:s,adapter:s,responseType:s,xsrfCookieName:s,xsrfHeaderName:s,onUploadProgress:s,onDownloadProgress:s,decompress:s,maxContentLength:s,maxBodyLength:s,beforeRedirect:s,transport:s,httpAgent:s,httpsAgent:s,cancelToken:s,socketPath:s,responseEncoding:s,validateStatus:a};return E.forEach(Object.keys(e).concat(Object.keys(t)),(function(e){var t=u[e]||o,n=t(e);E.isUndefined(n)&&t!==a||(r[e]=n)})),r},K="0.27.2",X=K,G={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){G[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}}));var Q={};G.transitional=function(e,t,r){function n(e,t){return"[Axios v"+X+"] Transitional option '"+e+"'"+t+(r?". "+r:"")}return function(r,o,i){if(!1===e)throw new T(n(o," has been removed"+(t?" in "+t:"")),T.ERR_DEPRECATED);return t&&!Q[o]&&(Q[o]=!0,console.warn(n(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(r,o,i)}};var Y={assertOptions:function(e,t,r){if("object"!=typeof e)throw new T("options must be an object",T.ERR_BAD_OPTION_VALUE);for(var n=Object.keys(e),o=n.length;o-- >0;){var i=n[o],s=t[i];if(s){var a=e[i],u=void 0===a||s(a,i,e);if(!0!==u)throw new T("option "+i+" must be "+u,T.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new T("Unknown option "+i,T.ERR_BAD_OPTION)}},validators:G},Z=Y.validators;function ee(e){this.defaults=e,this.interceptors={request:new R,response:new R}}ee.prototype.request=function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{},(t=V(this.defaults,t)).method?t.method=t.method.toLowerCase():this.defaults.method?t.method=this.defaults.method.toLowerCase():t.method="get";var r=t.transitional;void 0!==r&&Y.assertOptions(r,{silentJSONParsing:Z.transitional(Z.boolean),forcedJSONParsing:Z.transitional(Z.boolean),clarifyTimeoutError:Z.transitional(Z.boolean)},!1);var n=[],o=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(o=o&&e.synchronous,n.unshift(e.fulfilled,e.rejected))}));var i,s=[];if(this.interceptors.response.forEach((function(e){s.push(e.fulfilled,e.rejected)})),!o){var a=[H,void 0];for(Array.prototype.unshift.apply(a,n),a=a.concat(s),i=Promise.resolve(t);a.length;)i=i.then(a.shift(),a.shift());return i}for(var u=t;n.length;){var c=n.shift(),f=n.shift();try{u=c(u)}catch(e){f(e);break}}try{i=H(u)}catch(e){return Promise.reject(e)}for(;s.length;)i=i.then(s.shift(),s.shift());return i},ee.prototype.getUri=function(e){e=V(this.defaults,e);var t=P(e.baseURL,e.url);return b(t,e.params,e.paramsSerializer)},E.forEach(["delete","get","head","options"],(function(e){ee.prototype[e]=function(t,r){return this.request(V(r||{},{method:e,url:t,data:(r||{}).data}))}})),E.forEach(["post","put","patch"],(function(e){function t(t){return function(r,n,o){return this.request(V(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:r,data:n}))}}ee.prototype[e]=t(),ee.prototype[e+"Form"]=t(!0)}));var te=ee;function re(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;this.promise.then((function(e){if(r._listeners){var t,n=r._listeners.length;for(t=0;t<n;t++)r._listeners[t](e);r._listeners=null}})),this.promise.then=function(e){var t,n=new Promise((function(e){r.subscribe(e),t=e})).then(e);return n.cancel=function(){r.unsubscribe(t)},n},e((function(e){r.reason||(r.reason=new k(e),t(r.reason))}))}re.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},re.prototype.subscribe=function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]},re.prototype.unsubscribe=function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}},re.source=function(){var e;return{token:new re((function(t){e=t})),cancel:e}};var ne=re;var oe=function e(r){var n=new te(r),o=t(te.prototype.request,n);return E.extend(o,te.prototype,n),E.extend(o,n),o.create=function(t){return e(V(r,t))},o}(M);oe.Axios=te,oe.CanceledError=k,oe.CancelToken=ne,oe.isCancel=W,oe.VERSION=K,oe.toFormData=_,oe.AxiosError=T,oe.Cancel=oe.CanceledError,oe.all=function(e){return Promise.all(e)},oe.spread=function(e){return function(t){return e.apply(null,t)}},oe.isAxiosError=function(e){return E.isObject(e)&&!0===e.isAxiosError};var ie=oe,se=oe;ie.default=se;var ae=ie;const ue="1.11.12",ce="v5.0",fe=["v2","v3","v4","v5","canary"],le="@tryghost/content-api",de=e=>{let t;if("v5"===e||void 0===e||e.match(/^v5\.\d+/))t="/content/";else if(e.match(/^v\d+\.\d+/)){t=`/${/^(v\d+)\.\d+/.exec(e)[1]}/content/`}else t=`/${e}/content/`;return t},he=e=>{let{url:t,method:r,params:n,headers:o}=e;return ae[r](t,{params:n,paramsSerializer:e=>Object.keys(e).reduce(((t,r)=>{const n=encodeURIComponent([].concat(e[r]).join(","));return t.concat(`${r}=${n}`)}),[]).join("&"),headers:o})};return function e(t){let r,{url:n,key:o,host:i,version:s,userAgent:a,ghostPath:u="ghost",makeRequest:c=he}=t;if(i&&(console.warn(`${le}: The 'host' parameter is deprecated, please use 'url' instead`),n||(n=i)),this instanceof e)return e({url:n,key:o,version:s,userAgent:a,ghostPath:u,makeRequest:c});if(void 0===s)throw new Error(`${le} Config Missing: 'version' is required. E.g. ${fe.join(",")}`);if("boolean"==typeof s)!0===s&&(r=ce),s=void 0;else{if(s&&!fe.includes(s)&&!s.match(/^v\d+\.\d+/))throw new Error(`${le} Config Invalid: 'version' ${s} is not supported`);"canary"===s?(console.warn(`${le}: The 'version' parameter has a deprecated format 'canary', please use 'v{major}.{minor}' format instead`),r=ce):s.match(/^v\d+$/)?(console.warn(`${le}: The 'version' parameter has a deprecated format 'v{major}', please use 'v{major}.{minor}' format instead`),r=`${s}.0`):r=s}if(!n)throw new Error(`${le} Config Missing: 'url' is required. E.g. 'https://site.com'`);if(!/https?:\/\//.test(n))throw new Error(`${le} Config Invalid: 'url' ${n} requires a protocol. E.g. 'https://site.com'`);if(n.endsWith("/"))throw new Error(`${le} Config Invalid: 'url' ${n} must not have a trailing slash. E.g. 'https://site.com'`);if(u.endsWith("/")||u.startsWith("/"))throw new Error(`${le} Config Invalid: 'ghostPath' ${u} must not have a leading or trailing slash. E.g. 'ghost'`);if(o&&!/[0-9a-f]{26}/.test(o))throw new Error(`${le} Config Invalid: 'key' ${o} must have 26 hex characters`);void 0===a&&(a=false);const f=["posts","authors","tags","pages","settings","tiers","newsletters","offers"].reduce(((e,t)=>Object.assign(e,{[t]:{read:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;if(!e||!e.id&&!e.slug)return Promise.reject(new Error(`${le} read requires an id or slug.`));const o=Object.assign({},e,r);return l(t,o,e.id||`slug/${e.slug}`,n)},browse:function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;return l(t,e,null,r)}}})),{});return delete f.settings.read,delete f.tiers.read,delete f.newsletters.read,delete f.offers.browse,f;function l(e,t,i){let f=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null;if(!f&&!o)return Promise.reject(new Error(`${le} Config Missing: 'key' is required.`));delete t.id;const l=f?{Authorization:`GhostMembers ${f}`}:{};a&&(l["User-Agent"]="boolean"==typeof a?`GhostContentSDK/${ue}`:a),r&&(l["Accept-Version"]=r),t=Object.assign({key:o},t);const d=`${n}/${u}/api${de(s)}${e}/${i?i+"/":""}`;return c({url:d,method:"get",params:t,headers:l}).then((t=>Array.isArray(t.data[e])?1!==t.data[e].length||t.data.meta?Object.assign(t.data[e],{meta:t.data.meta}):t.data[e][0]:t.data[e])).catch((e=>{if(e.response&&e.response.data&&e.response.data.errors){const t=e.response.data.errors[0],r=new Error(t.message),n=Object.keys(t);throw r.name=t.type,n.forEach((e=>{r[e]=t[e]})),r.response=e.response,r.request=e.request,r.config=e.config,r}throw e}))}}}));
|
|
2
2
|
//# sourceMappingURL=content-api.min.js.map
|