gist-wrapper
Advanced tools
Comparing version 0.3.0 to 0.4.0
@@ -22,6 +22,6 @@ import { AxiosInstance } from 'axios'; | ||
patch(url: string, data?: Data | undefined, config?: {}): Promise<import("axios").AxiosResponse<any>>; | ||
create(data: Data): Promise<import("axios").AxiosResponse<any>>; | ||
update(gistId: string, data: Data): Promise<import("axios").AxiosResponse<any>>; | ||
getOne(gistId: string): Promise<import("axios").AxiosResponse<any>>; | ||
delOne(gistId: string): Promise<import("axios").AxiosResponse<any>>; | ||
create(data: Data, conf: Config | undefined): Promise<import("axios").AxiosResponse<any>>; | ||
update(gistId: string, data: Data, conf: Config | undefined): Promise<import("axios").AxiosResponse<any>>; | ||
getOne(gistId: string, conf: Config | undefined): Promise<import("axios").AxiosResponse<any>>; | ||
delOne(gistId: string, conf: Config | undefined): Promise<import("axios").AxiosResponse<any>>; | ||
_patchHeaders(headers: Data): { | ||
@@ -28,0 +28,0 @@ 'X-User-Agent': string; |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("axios")):"function"==typeof define&&define.amd?define(["axios"],e):"object"==typeof exports?exports.GitHubGist=e(require("axios")):t.GitHubGist=e(t.axios)}(this,(function(t){return(()=>{"use strict";var e={546:function(t,e,s){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.HTTPError=void 0;const i=r(s(375));class n extends Error{constructor(t,e,s,r){super(`status: ${t}\nstatusText: ${e}\ndata: ${JSON.stringify(s,null,2)}\nconfig: ${JSON.stringify(r,null,2)}`),this.status=t,this.statusText=e,this.data=s,this.config=r}}e.HTTPError=n,e.default=class{constructor(t,e="github-gist-client-js/v0.3.0"){this.token=t,this.server="https://api.github.com",this.userAgentHeader=e,this._axios=i.default.create();const s=this._axios.request.bind(this._axios);this._axios.request=t=>{try{return s(t)}catch(t){throw t.response?new n(t.response.status,t.response.statusText,t.response.data,t.response.config):t}}}request(t){const e=t.url.startsWith("http")?t.url:this.server+t.url;return this._axios.request(Object.assign(Object.assign({},t),{url:e.toString(),headers:this._patchHeaders(t.headers)}))}get(t,e={}){return this.request(Object.assign(Object.assign({},e),{method:"get",url:t}))}delete(t,e={}){return this.request(Object.assign(Object.assign({},e),{method:"delete",url:t}))}post(t,e,s={}){return this.request(Object.assign(Object.assign({},s),{method:"post",url:t,data:e}))}put(t,e,s={}){return this.request(Object.assign(Object.assign({},s),{method:"put",url:t,data:e}))}patch(t,e,s={}){return this.request(Object.assign(Object.assign({},s),{method:"patch",url:t,data:e}))}create(t){return this.post("/gists",t)}update(t,e){return this.patch(`/gists/${t}`,e)}getOne(t){return this.get(`/gists/${t}`)}delOne(t){return this.delete(`/gists/${t}`)}_patchHeaders(t){return Object.assign(Object.assign(Object.assign({},this._authHeader()),{"X-User-Agent":this.userAgentHeader}),t)}_authHeader(){return this.token?{Authorization:`token ${this.token}`}:{}}}},375:e=>{e.exports=t}},s={};return function t(r){if(s[r])return s[r].exports;var i=s[r]={exports:{}};return e[r].call(i.exports,i,i.exports,t),i.exports}(546)})()})); | ||
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("axios")):"function"==typeof define&&define.amd?define(["axios"],e):"object"==typeof exports?exports.GitHubGist=e(require("axios")):t.GitHubGist=e(t.axios)}(this,(function(t){return(()=>{"use strict";var e={546:function(t,e,s){var r=this&&this.__importDefault||function(t){return t&&t.__esModule?t:{default:t}};Object.defineProperty(e,"__esModule",{value:!0}),e.HTTPError=void 0;const i=r(s(375));class n extends Error{constructor(t,e,s,r){super(`status: ${t}\nstatusText: ${e}\ndata: ${JSON.stringify(s,null,2)}\nconfig: ${JSON.stringify(r,null,2)}`),this.status=t,this.statusText=e,this.data=s,this.config=r}}e.HTTPError=n,e.default=class{constructor(t,e="github-gist-client-js/v0.4.0"){this.token=t,this.server="https://api.github.com",this.userAgentHeader=e,this._axios=i.default.create();const s=this._axios.request.bind(this._axios);this._axios.request=t=>{try{return s(t)}catch(t){throw t.response?new n(t.response.status,t.response.statusText,t.response.data,t.response.config):t}}}request(t){const e=t.url.startsWith("http")?t.url:this.server+t.url;return this._axios.request(Object.assign(Object.assign({},t),{url:e.toString(),headers:this._patchHeaders(t.headers)}))}get(t,e={}){return this.request(Object.assign(Object.assign({},e),{method:"get",url:t}))}delete(t,e={}){return this.request(Object.assign(Object.assign({},e),{method:"delete",url:t}))}post(t,e,s={}){return this.request(Object.assign(Object.assign({},s),{method:"post",url:t,data:e}))}put(t,e,s={}){return this.request(Object.assign(Object.assign({},s),{method:"put",url:t,data:e}))}patch(t,e,s={}){return this.request(Object.assign(Object.assign({},s),{method:"patch",url:t,data:e}))}create(t,e){return this.post("/gists",t,e)}update(t,e,s){return this.patch(`/gists/${t}`,e,s)}getOne(t,e){return this.get(`/gists/${t}`,e)}delOne(t,e){return this.delete(`/gists/${t}`,e)}_patchHeaders(t){return Object.assign(Object.assign(Object.assign({},this._authHeader()),{"X-User-Agent":this.userAgentHeader}),t)}_authHeader(){return this.token?{Authorization:`token ${this.token}`}:{}}}},375:e=>{e.exports=t}},s={};return function t(r){if(s[r])return s[r].exports;var i=s[r]={exports:{}};return e[r].call(i.exports,i,i.exports,t),i.exports}(546)})()})); | ||
//# sourceMappingURL=gist.js.map |
{ | ||
"name": "gist-wrapper", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Github gist API wrapper.", | ||
@@ -5,0 +5,0 @@ "author": "ZHAO Xudong <zxdong@gmail.com>", |
@@ -83,16 +83,16 @@ // based on tyler's work: https://github.com/tylerlong/ringcentral-js-concise | ||
create (data: Data) { | ||
return this.post('/gists', data) | ||
create (data: Data, conf: Config | undefined) { | ||
return this.post('/gists', data, conf) | ||
} | ||
update (gistId: string, data: Data) { | ||
return this.patch(`/gists/${gistId}`, data) | ||
update (gistId: string, data: Data, conf: Config | undefined) { | ||
return this.patch(`/gists/${gistId}`, data, conf) | ||
} | ||
getOne (gistId: string) { | ||
return this.get(`/gists/${gistId}`) | ||
getOne (gistId: string, conf: Config | undefined) { | ||
return this.get(`/gists/${gistId}`, conf) | ||
} | ||
delOne (gistId: string) { | ||
return this.delete(`/gists/${gistId}`) | ||
delOne (gistId: string, conf: Config | undefined) { | ||
return this.delete(`/gists/${gistId}`, conf) | ||
} | ||
@@ -99,0 +99,0 @@ |
@@ -12,2 +12,3 @@ { | ||
}, | ||
"useUnknownInCatchVariables": false, | ||
"include": ["./src/*.ts"], | ||
@@ -14,0 +15,0 @@ "$schema": "https://json.schemastore.org/tsconfig", |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
19853
185
0