7567
This commit is contained in:
1 parent
83b90b2536
commit
91399bb457
209 files changed
+780
-1029
No files matched your search
@@ -0,0 +1,11 @@
|
||||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Artalk={})}(this,(function(e){"use strict";var t,n,s,i,r=Object.defineProperty,o=Object.defineProperties,a=Object.getOwnPropertyDescriptors,l=Object.getOwnPropertySymbols,c=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,h=(e,t,n)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,u=(e,t)=>{for(var n in t||(t={}))c.call(t,n)&&h(e,n,t[n]);if(l)for(var n of l(t))d.call(t,n)&&h(e,n,t[n]);return e},p=(e,t)=>o(e,a(t)),g=(e,t,n)=>(h(e,"symbol"!=typeof t?t+"":t,n),n),m=(e,t,n)=>{if(t.has(e))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(e):t.set(e,n)},f=(e,t,n)=>(((e,t,n)=>{if(!t.has(e))throw TypeError("Cannot "+n)})(e,t,"access private method"),n),k=(e,t,n)=>new Promise(((s,i)=>{var r=e=>{try{a(n.next(e))}catch(t){i(t)}},o=e=>{try{a(n.throw(e))}catch(t){i(t)}},a=e=>e.done?s(e.value):Promise.resolve(e.value).then(r,o);a((n=n.apply(e,t)).next())}));class y{constructor(e={}){g(this,"baseUrl","/api/v2"),g(this,"securityData",null),g(this,"securityWorker"),g(this,"abortControllers",new Map),g(this,"customFetch",((...e)=>fetch(...e))),g(this,"baseApiParams",{credentials:"same-origin",headers:{},redirect:"follow",referrerPolicy:"no-referrer"}),g(this,"setSecurityData",(e=>{this.securityData=e})),g(this,"contentFormatters",{"application/json":e=>null===e||"object"!=typeof e&&"string"!=typeof e?e:JSON.stringify(e),"text/plain":e=>null!==e&&"string"!=typeof e?JSON.stringify(e):e,"multipart/form-data":e=>Object.keys(e||{}).reduce(((t,n)=>{const s=e[n];return t.append(n,s instanceof Blob?s:"object"==typeof s&&null!==s?JSON.stringify(s):`${s}`),t}),new FormData),"application/x-www-form-urlencoded":e=>this.toQueryString(e)}),g(this,"createAbortSignal",(e=>{if(this.abortControllers.has(e)){const t=this.abortControllers.get(e);return t?t.signal:void 0}const t=new AbortController;return this.abortControllers.set(e,t),t.signal})),g(this,"abortRequest",(e=>{const t=this.abortControllers.get(e);t&&(t.abort(),this.abortControllers.delete(e))})),g(this,"request",(e=>k(this,null,(function*(){var t=e,{body:n,secure:s,path:i,type:r,query:o,format:a,baseUrl:h,cancelToken:g}=t,m=((e,t)=>{var n={};for(var s in e)c.call(e,s)&&t.indexOf(s)<0&&(n[s]=e[s]);if(null!=e&&l)for(var s of l(e))t.indexOf(s)<0&&d.call(e,s)&&(n[s]=e[s]);return n})(t,["body","secure","path","type","query","format","baseUrl","cancelToken"]);const f=("boolean"==typeof s?s:this.baseApiParams.secure)&&this.securityWorker&&(yield this.securityWorker(this.securityData))||{},y=this.mergeRequestParams(m,f),v=o&&this.toQueryString(o),$=this.contentFormatters[r||"application/json"],b=a||y.format;return this.customFetch(`${h||this.baseUrl||""}${i}${v?`?${v}`:""}`,p(u({},y),{headers:u(u({},y.headers||{}),r&&"multipart/form-data"!==r?{"Content-Type":r}:{}),signal:(g?this.createAbortSignal(g):y.signal)||null,body:null==n?null:$(n)})).then((e=>k(this,null,(function*(){const t=e;t.data=null,t.error=null;const n=b?yield e[b]().then((e=>(t.ok?t.data=e:t.error=e,t))).catch((e=>(t.error=e,t))):t;if(g&&this.abortControllers.delete(g),!e.ok)throw n;return n}))))})))),Object.assign(this,e)}encodeQueryParam(e,t){return`${encodeURIComponent(e)}=${encodeURIComponent("number"==typeof t?t:`${t}`)}`}addQueryParam(e,t){return this.encodeQueryParam(t,e[t])}addArrayQueryParam(e,t){return e[t].map((e=>this.encodeQueryParam(t,e))).join("&")}toQueryString(e){const t=e||{};return Object.keys(t).filter((e=>void 0!==t[e])).map((e=>Array.isArray(t[e])?this.addArrayQueryParam(t,e):this.addQueryParam(t,e))).join("&")}addQueryParams(e){const t=this.toQueryString(e);return t?`?${t}`:""}mergeRequestParams(e,t){return p(u(u(u({},this.baseApiParams),e),t||{}),{headers:u(u(u({},this.baseApiParams.headers||{}),e.headers||{}),t&&t.headers||{})})}}
|
||||
/**
|
||||
* @title Artalk API
|
||||
* @version 2.0
|
||||
* @license MIT (https://github.com/ArtalkJS/Artalk/blob/master/LICENSE)
|
||||
* @baseUrl /api/v2
|
||||
* @contact API Support <artalkjs@gmail.com> (https://artalk.js.org)
|
||||
*
|
||||
* Artalk is a modern comment system based on Golang.
|
||||
*/let v=class extends y{constructor(){super(...arguments),g(this,"auth",{loginByEmail:(e,t={})=>this.request(u({path:"/auth/email/login",method:"POST",body:e,type:"application/json",format:"json"},t)),registerByEmail:(e,t={})=>this.request(u({path:"/auth/email/register",method:"POST",body:e,type:"application/json",format:"json"},t)),sendVerifyEmail:(e,t={})=>this.request(u({path:"/auth/email/send",method:"POST",body:e,type:"application/json",format:"json"},t)),checkDataMerge:(e={})=>this.request(u({path:"/auth/merge",method:"GET",secure:!0,format:"json"},e)),applyDataMerge:(e,t={})=>this.request(u({path:"/auth/merge",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t))}),g(this,"cache",{flushCache:(e={})=>this.request(u({path:"/cache/flush",method:"POST",secure:!0,format:"json"},e)),warmUpCache:(e={})=>this.request(u({path:"/cache/warm_up",method:"POST",secure:!0,format:"json"},e))}),g(this,"captcha",{getCaptcha:(e={})=>this.request(u({path:"/captcha",method:"GET",format:"json"},e)),getCaptchaStatus:(e={})=>this.request(u({path:"/captcha/status",method:"GET",format:"json"},e)),verifyCaptcha:(e,t={})=>this.request(u({path:"/captcha/verify",method:"POST",body:e,type:"application/json",format:"json"},t))}),g(this,"comments",{getComments:(e,t={})=>this.request(u({path:"/comments",method:"GET",query:e,secure:!0,type:"application/json",format:"json"},t)),createComment:(e,t={})=>this.request(u({path:"/comments",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),getComment:(e,t={})=>this.request(u({path:`/comments/${e}`,method:"GET",type:"application/json",format:"json"},t)),updateComment:(e,t,n={})=>this.request(u({path:`/comments/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deleteComment:(e,t={})=>this.request(u({path:`/comments/${e}`,method:"DELETE",secure:!0,format:"json"},t))}),g(this,"conf",{conf:(e={})=>this.request(u({path:"/conf",method:"GET",format:"json"},e)),getSocialLoginProviders:(e={})=>this.request(u({path:"/conf/auth/providers",method:"GET",format:"json"},e)),getDomain:(e,t={})=>this.request(u({path:"/conf/domain",method:"GET",query:e,format:"json"},t))}),g(this,"notifies",{getNotifies:(e,t={})=>this.request(u({path:"/notifies",method:"GET",query:e,type:"application/json",format:"json"},t)),markAllNotifyRead:(e,t={})=>this.request(u({path:"/notifies/read",method:"POST",body:e,type:"application/json",format:"json"},t)),markNotifyRead:(e,t,n={})=>this.request(u({path:`/notifies/${e}/${t}`,method:"POST",format:"json"},n))}),g(this,"pages",{getPages:(e,t={})=>this.request(u({path:"/pages",method:"GET",query:e,secure:!0,type:"application/json",format:"json"},t)),fetchAllPages:(e,t={})=>this.request(u({path:"/pages/fetch",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),getPageFetchStatus:(e={})=>this.request(u({path:"/pages/fetch/status",method:"GET",secure:!0,format:"json"},e)),logPv:(e,t={})=>this.request(u({path:"/pages/pv",method:"POST",body:e,type:"application/json",format:"json"},t)),updatePage:(e,t,n={})=>this.request(u({path:`/pages/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deletePage:(e,t={})=>this.request(u({path:`/pages/${e}`,method:"DELETE",secure:!0,format:"json"},t)),fetchPage:(e,t={})=>this.request(u({path:`/pages/${e}/fetch`,method:"POST",secure:!0,type:"application/json",format:"json"},t))}),g(this,"sendEmail",{sendEmail:(e,t={})=>this.request(u({path:"/send_email",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t))}),g(this,"settings",{getSettings:(e={})=>this.request(u({path:"/settings",method:"GET",secure:!0,format:"json"},e)),applySettings:(e,t={})=>this.request(u({path:"/settings",method:"PUT",body:e,secure:!0,type:"application/json",format:"json"},t)),getSettingsTemplate:(e,t={})=>this.request(u({path:`/settings/template/${e}`,method:"GET",secure:!0,format:"json"},t))}),g(this,"sites",{getSites:(e={})=>this.request(u({path:"/sites",method:"GET",secure:!0,format:"json"},e)),createSite:(e,t={})=>this.request(u({path:"/sites",method:"POST",body:e,secure:!0,type:"application/json",format:"json"},t)),updateSite:(e,t,n={})=>this.request(u({path:`/sites/${e}`,method:"PUT",body:t,secure:!0,type:"application/json",format:"json"},n)),deleteSite:(e,t={})=>this.request(u({path:`/sites/${e}`,method:"DELETE",secure:!0,format:"json"},t))}),g(this,"stats",{getStats:(e,t,n={})=>this.request(u({path:`/stats/${e}`,method:"GET",query:t,type:"application/json",format:"json"},n))}),g(this,"transfer",{exportArtrans:(e={})=>this.request(u({path:"/transfer/export",method:"GET",secure:!0,format:"json"},e)),importArtrans:(e,t={})=>this.request(u({path:"/transfer/import",method:"POST",body:e,secure:!0,type:"application/json"},t)),uploadArtrans:(e,t={})=>this.request(u({path:"/transfer/upload",method:"POST",body:e,secure:!0,type:"multipart/form-data",format:"json"},t))}),g(this,"upload",{upload:(e,t={})=>this.request(u({path:"/upload",method:"POSLine truncated
|
||||
//# sourceMappingURL=Artalk.js.map
|
||||
Reference in new issue
Block a user