Comparing version 9.1.16 to 9.1.17
@@ -6,2 +6,20 @@ # Change Log | ||
## [9.1.17](https://github.com/wopian/kitsu/tree/master/packages/kitsu/compare/v9.1.16...v9.1.17) (2020-12-06) | ||
### Chores | ||
* **release:** update documentation ([89746a8](https://github.com/wopian/kitsu/tree/master/packages/kitsu/commit/89746a8)) | ||
### Documentation Changes | ||
* **kitsu:** add missing commas to quick start ([5c02d2b](https://github.com/wopian/kitsu/tree/master/packages/kitsu/commit/5c02d2b)) | ||
* **kitsu:** example for JSON:API 1.1 nested filters ([d733c63](https://github.com/wopian/kitsu/tree/master/packages/kitsu/commit/d733c63)) | ||
## [9.1.16](https://github.com/wopian/kitsu/tree/master/packages/kitsu/compare/v9.1.15...v9.1.16) (2020-10-25) | ||
@@ -8,0 +26,0 @@ |
@@ -1,1 +0,1 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var s=e(require("axios")),a=e(require("pluralize")),t=require("kitsu-core");module.exports=class{constructor(e={}){!1===e.camelCaseTypes?this.camel=e=>e:this.camel=t.camel,"none"===e.resourceCase?this.resCase=e=>e:"snake"===e.resourceCase?this.resCase=t.snake:this.resCase=t.kebab,!1===e.pluralize?this.plural=e=>e:this.plural=a,this.headers=Object.assign({},e.headers,{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json"}),this.axios=s.create(Object.assign({},{baseURL:e.baseURL||"https://kitsu.io/api/edge",timeout:e.timeout||3e4},e.axiosOptions)),this.fetch=this.get,this.update=this.patch,this.create=this.post,this.remove=this.delete,this.interceptors=this.axios.interceptors}async get(e,s={},a={}){try{const[r,i,l]=e.split("/");let c=this.plural(this.resCase(r));i&&(c+="/".concat(i)),l&&(c+="/".concat(this.resCase(l)));const{data:h}=await this.axios.get(c,{params:s,paramsSerializer:e=>t.query(e),headers:Object.assign(this.headers,a)});return t.deserialise(h)}catch(e){throw t.error(e)}}async patch(e,s,a={}){try{const[r,i]=t.splitModel(e,{resourceCase:this.resCase,pluralModel:this.plural}),l=t.serialise(r,s,"PATCH",{camelCaseTypes:this.camel,pluralTypes:this.plural}),c=(null==s?void 0:s.id)?"".concat(i,"/").concat(s.id):i,{data:h}=await this.axios.patch(c,l,{headers:Object.assign(this.headers,a)});return t.deserialise(h)}catch(e){throw t.error(e)}}async post(e,s,a={}){try{const[r,i]=t.splitModel(e,{resourceCase:this.resCase,pluralModel:this.plural}),{data:l}=await this.axios.post(i,t.serialise(r,s,"POST",{camelCaseTypes:this.camel,pluralTypes:this.plural}),{headers:Object.assign(this.headers,a)});return t.deserialise(l)}catch(e){throw t.error(e)}}async delete(e,s,a={}){try{const[r,i]=t.splitModel(e,{resourceCase:this.resCase,pluralModel:this.plural});let l,c;Array.isArray(s)?(l=i,c=s.map(e=>({id:e}))):(l="".concat(i,"/").concat(s),c={id:s});const{data:h}=await this.axios.delete(l,{data:t.serialise(r,c,"DELETE",{camelCaseTypes:this.camel,pluralTypes:this.plural}),headers:Object.assign(this.headers,a)});return h}catch(e){throw t.error(e)}}async self(e={},s={}){try{return(await this.get("users",Object.assign({filter:{self:!0}},e),s)).data[0]}catch(e){throw t.error(e)}}async request({body:e,method:s,params:a,type:r,url:i},l={}){try{var c;s=(null===(c=s)||void 0===c?void 0:c.toUpperCase())||"GET";const{data:h}=await this.axios.request({method:s,url:i,data:["GET","DELETE"].includes(s)?void 0:t.serialise(r,e,s,{camelCaseTypes:this.camel,pluralTypes:this.plural}),params:a,paramsSerializer:e=>t.query(e),headers:Object.assign(this.headers,l)});return t.deserialise(h)}catch(e){throw t.error(e)}}}; | ||
"use strict";var e=require("axios"),s=require("pluralize"),a=require("kitsu-core");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var r=t(e),i=t(s);module.exports=class{constructor(e={}){!1===e.camelCaseTypes?this.camel=e=>e:this.camel=a.camel,"none"===e.resourceCase?this.resCase=e=>e:"snake"===e.resourceCase?this.resCase=a.snake:this.resCase=a.kebab,!1===e.pluralize?this.plural=e=>e:this.plural=i.default,this.headers=Object.assign({},e.headers,{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json"}),this.axios=r.default.create(Object.assign({},{baseURL:e.baseURL||"https://kitsu.io/api/edge",timeout:e.timeout||3e4},e.axiosOptions)),this.fetch=this.get,this.update=this.patch,this.create=this.post,this.remove=this.delete,this.interceptors=this.axios.interceptors}async get(e,s={},t={}){try{const[r,i,l]=e.split("/");let c=this.plural(this.resCase(r));i&&(c+="/".concat(i)),l&&(c+="/".concat(this.resCase(l)));const{data:h}=await this.axios.get(c,{params:s,paramsSerializer:e=>a.query(e),headers:Object.assign(this.headers,t)});return a.deserialise(h)}catch(e){throw a.error(e)}}async patch(e,s,t={}){try{const[r,i]=a.splitModel(e,{resourceCase:this.resCase,pluralModel:this.plural}),l=a.serialise(r,s,"PATCH",{camelCaseTypes:this.camel,pluralTypes:this.plural}),c=null!=s&&s.id?"".concat(i,"/").concat(s.id):i,{data:h}=await this.axios.patch(c,l,{headers:Object.assign(this.headers,t)});return a.deserialise(h)}catch(e){throw a.error(e)}}async post(e,s,t={}){try{const[r,i]=a.splitModel(e,{resourceCase:this.resCase,pluralModel:this.plural}),{data:l}=await this.axios.post(i,a.serialise(r,s,"POST",{camelCaseTypes:this.camel,pluralTypes:this.plural}),{headers:Object.assign(this.headers,t)});return a.deserialise(l)}catch(e){throw a.error(e)}}async delete(e,s,t={}){try{const[r,i]=a.splitModel(e,{resourceCase:this.resCase,pluralModel:this.plural});let l,c;Array.isArray(s)?(l=i,c=s.map((e=>({id:e})))):(l="".concat(i,"/").concat(s),c={id:s});const{data:h}=await this.axios.delete(l,{data:a.serialise(r,c,"DELETE",{camelCaseTypes:this.camel,pluralTypes:this.plural}),headers:Object.assign(this.headers,t)});return h}catch(e){throw a.error(e)}}async self(e={},s={}){try{return(await this.get("users",Object.assign({filter:{self:!0}},e),s)).data[0]}catch(e){throw a.error(e)}}async request({body:e,method:s,params:t,type:r,url:i},l={}){try{var c;s=(null===(c=s)||void 0===c?void 0:c.toUpperCase())||"GET";const{data:h}=await this.axios.request({method:s,url:i,data:["GET","DELETE"].includes(s)?void 0:a.serialise(r,e,s,{camelCaseTypes:this.camel,pluralTypes:this.plural}),params:t,paramsSerializer:e=>a.query(e),headers:Object.assign(this.headers,l)});return a.deserialise(h)}catch(e){throw a.error(e)}}}; |
{ | ||
"version": "9.1.16", | ||
"version": "9.1.17", | ||
"name": "kitsu", | ||
@@ -51,3 +51,3 @@ "description": "A simple, lightweight & framework agnostic JSON:API client using Axios", | ||
"axios": "^0.21.0", | ||
"kitsu-core": "^9.1.16", | ||
"kitsu-core": "^9.1.17", | ||
"pluralize": "^8.0.0" | ||
@@ -67,3 +67,3 @@ }, | ||
], | ||
"gitHead": "582d319c5f3b3feec935d8973655b62892d54971", | ||
"gitHead": "c7d71b9c910c608de00fa2241ff8a15ff49ad26e", | ||
"devDependencies": { | ||
@@ -70,0 +70,0 @@ "@size-limit/preset-small-lib": "~4.5.0" |
@@ -160,6 +160,6 @@ <h1 align=center>Kitsu</h1> | ||
users: 'slug,followers,waifu' | ||
} | ||
}, | ||
filter: { | ||
slug: 'wopian' | ||
} | ||
}, | ||
sort: '-id', | ||
@@ -213,3 +213,3 @@ page: { | ||
[packages/kitsu/src/index.js:30-464](https://github.com/wopian/kitsu/blob/1015412d29679a4c4666598dbb6a7ad907d8c391/packages/kitsu/src/index.js#L30-L464 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:30-473](https://github.com/wopian/kitsu/blob/d733c6351273481aa9207366784e3c8748681fa3/packages/kitsu/src/index.js#L30-L473 "Source code on GitHub") | ||
@@ -261,3 +261,3 @@ Creates a new `kitsu` instance | ||
[packages/kitsu/src/index.js:52-53](https://github.com/wopian/kitsu/blob/1015412d29679a4c4666598dbb6a7ad907d8c391/packages/kitsu/src/index.js#L52-L53 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:52-53](https://github.com/wopian/kitsu/blob/d733c6351273481aa9207366784e3c8748681fa3/packages/kitsu/src/index.js#L52-L53 "Source code on GitHub") | ||
@@ -284,3 +284,3 @@ - **See: <https://www.npmjs.com/package/pluralize> for documentation | ||
[packages/kitsu/src/index.js:67-67](https://github.com/wopian/kitsu/blob/1015412d29679a4c4666598dbb6a7ad907d8c391/packages/kitsu/src/index.js#L67-L67 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:67-67](https://github.com/wopian/kitsu/blob/d733c6351273481aa9207366784e3c8748681fa3/packages/kitsu/src/index.js#L67-L67 "Source code on GitHub") | ||
@@ -316,3 +316,3 @@ Get the current headers or add additional headers | ||
[packages/kitsu/src/index.js:112-112](https://github.com/wopian/kitsu/blob/1015412d29679a4c4666598dbb6a7ad907d8c391/packages/kitsu/src/index.js#L112-L112 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:112-112](https://github.com/wopian/kitsu/blob/d733c6351273481aa9207366784e3c8748681fa3/packages/kitsu/src/index.js#L112-L112 "Source code on GitHub") | ||
@@ -368,3 +368,3 @@ - **See: <https://github.com/axios/axios#interceptors> for documentation | ||
[packages/kitsu/src/index.js:189-208](https://github.com/wopian/kitsu/blob/1015412d29679a4c4666598dbb6a7ad907d8c391/packages/kitsu/src/index.js#L189-L208 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:198-217](https://github.com/wopian/kitsu/blob/d733c6351273481aa9207366784e3c8748681fa3/packages/kitsu/src/index.js#L198-L217 "Source code on GitHub") | ||
@@ -441,2 +441,16 @@ Fetch resources (alias `fetch`) | ||
Getting a resource with nested JSON:API filters (not supported by Kitsu.io's API) | ||
```javascript | ||
// resource?filter[x][y]=value | ||
api.get('resource', { | ||
filter: { | ||
x: { | ||
y: 'value' | ||
} | ||
} | ||
} | ||
``` | ||
Handling errors (async/await) | ||
@@ -486,3 +500,3 @@ | ||
[packages/kitsu/src/index.js:241-262](https://github.com/wopian/kitsu/blob/1015412d29679a4c4666598dbb6a7ad907d8c391/packages/kitsu/src/index.js#L241-L262 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:250-271](https://github.com/wopian/kitsu/blob/d733c6351273481aa9207366784e3c8748681fa3/packages/kitsu/src/index.js#L250-L271 "Source code on GitHub") | ||
@@ -550,3 +564,3 @@ Update a resource (alias `update`) | ||
[packages/kitsu/src/index.js:290-309](https://github.com/wopian/kitsu/blob/1015412d29679a4c4666598dbb6a7ad907d8c391/packages/kitsu/src/index.js#L290-L309 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:299-318](https://github.com/wopian/kitsu/blob/d733c6351273481aa9207366784e3c8748681fa3/packages/kitsu/src/index.js#L299-L318 "Source code on GitHub") | ||
@@ -594,3 +608,3 @@ Create a new resource (alias `create`) | ||
[packages/kitsu/src/index.js:324-353](https://github.com/wopian/kitsu/blob/1015412d29679a4c4666598dbb6a7ad907d8c391/packages/kitsu/src/index.js#L324-L353 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:333-362](https://github.com/wopian/kitsu/blob/d733c6351273481aa9207366784e3c8748681fa3/packages/kitsu/src/index.js#L333-L362 "Source code on GitHub") | ||
@@ -625,3 +639,3 @@ Remove a resource (alias `remove`) | ||
[packages/kitsu/src/index.js:375-382](https://github.com/wopian/kitsu/blob/1015412d29679a4c4666598dbb6a7ad907d8c391/packages/kitsu/src/index.js#L375-L382 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:384-391](https://github.com/wopian/kitsu/blob/d733c6351273481aa9207366784e3c8748681fa3/packages/kitsu/src/index.js#L384-L391 "Source code on GitHub") | ||
@@ -663,3 +677,3 @@ Get the authenticated user's data | ||
[packages/kitsu/src/index.js:443-463](https://github.com/wopian/kitsu/blob/1015412d29679a4c4666598dbb6a7ad907d8c391/packages/kitsu/src/index.js#L443-L463 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:452-472](https://github.com/wopian/kitsu/blob/d733c6351273481aa9207366784e3c8748681fa3/packages/kitsu/src/index.js#L452-L472 "Source code on GitHub") | ||
@@ -666,0 +680,0 @@ Send arbitrary requests |
@@ -140,2 +140,11 @@ /** | ||
* api.get('anime/2/categories') | ||
* @example <caption>Getting a resource with nested JSON:API filters (not supported by Kitsu.io's API)</caption> | ||
* // resource?filter[x][y]=value | ||
* api.get('resource', { | ||
* filter: { | ||
* x: { | ||
* y: 'value' | ||
* } | ||
* } | ||
* } | ||
* @example <caption>Handling errors (async/await)</caption> | ||
@@ -142,0 +151,0 @@ * try { |
Sorry, the diff of this file is not supported yet
70248
391
780
Updatedkitsu-core@^9.1.17