Comparing version 9.1.11 to 10.0.0-alpha.0
@@ -6,2 +6,35 @@ # Change Log | ||
# [10.0.0-alpha.0](https://github.com/wopian/kitsu/tree/master/packages/kitsu/compare/v9.1.11...v10.0.0-alpha.0) (2020-06-15) | ||
### Chores | ||
* **release:** update documentation ([da50d92](https://github.com/wopian/kitsu/tree/master/packages/kitsu/commit/da50d92)) | ||
### Documentation Changes | ||
* update READMEs ([469d23a](https://github.com/wopian/kitsu/tree/master/packages/kitsu/commit/469d23a)) | ||
* **kitsu:** add v10 migration guide ([eb79c78](https://github.com/wopian/kitsu/tree/master/packages/kitsu/commit/eb79c78)) | ||
### New Features | ||
* **kitsu:** delete - add param parameter ([85a192b](https://github.com/wopian/kitsu/tree/master/packages/kitsu/commit/85a192b)) | ||
* **kitsu:** patch - add params parameter ([8d8eda3](https://github.com/wopian/kitsu/tree/master/packages/kitsu/commit/8d8eda3)) | ||
* **kitsu:** post - add params parameter ([13686be](https://github.com/wopian/kitsu/tree/master/packages/kitsu/commit/13686be)) | ||
### Refactors | ||
* **kitsu:** merge params and headers parameters into a single config object ([f98eef9](https://github.com/wopian/kitsu/tree/master/packages/kitsu/commit/f98eef9)) | ||
* **kitsu:** request - move headers into config object ([85937c4](https://github.com/wopian/kitsu/tree/master/packages/kitsu/commit/85937c4)) | ||
* **kitsu:** self - move params and headers into a config object ([c55949a](https://github.com/wopian/kitsu/tree/master/packages/kitsu/commit/c55949a)) | ||
* **kitsu:** use merge-options instead of Object.assign ([8b49cc1](https://github.com/wopian/kitsu/tree/master/packages/kitsu/commit/8b49cc1)) | ||
* **kitsu:** use merge-options instead of Object.assign for class constructor options ([9a162a0](https://github.com/wopian/kitsu/tree/master/packages/kitsu/commit/9a162a0)) | ||
## [9.1.11](https://github.com/wopian/kitsu/tree/master/packages/kitsu/compare/v9.1.10...v9.1.11) (2020-06-14) | ||
@@ -8,0 +41,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";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var s=require("kitsu-core"),a=e(require("axios")),r=e(require("merge-options")),t=e(require("pluralize"));module.exports=class{constructor(e={}){!1===e.camelCaseTypes?this.camel=e=>e:this.camel=s.camel,"none"===e.resourceCase?this.resCase=e=>e:"snake"===e.resourceCase?this.resCase=s.snake:this.resCase=s.kebab,!1===e.pluralize?this.plural=e=>e:this.plural=t,this.headers=r({Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json"},e.headers),this.axios=a.create(r({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,a={}){try{const t=r(this.headers,a.headers),i=r({},a.params),[l,h,o]=e.split("/");let p=this.plural(this.resCase(l));h&&(p+="/".concat(h)),o&&(p+="/".concat(this.resCase(o)));const{data:c}=await this.axios.get(p,{headers:t,params:i,paramsSerializer:e=>s.query(e)});return s.deserialise(c)}catch(e){throw s.error(e)}}async patch(e,a,t={}){try{const i=r(this.headers,t.headers),l=r({},t.params),[h,o]=s.splitModel(e,{resourceCase:this.resCase,pluralModel:this.plural}),p=s.serialise(h,a,"PATCH",{camelCaseTypes:this.camel,pluralTypes:this.plural}),c=(null==a?void 0:a.id)?"".concat(o,"/").concat(a.id):o,{data:d}=await this.axios.patch(c,p,{headers:i,params:l,paramsSerializer:e=>s.query(e)});return s.deserialise(d)}catch(e){throw s.error(e)}}async post(e,a,t={}){try{const i=r(this.headers,t.headers),l=r({},t.params),[h,o]=s.splitModel(e,{resourceCase:this.resCase,pluralModel:this.plural}),{data:p}=await this.axios.post(o,s.serialise(h,a,"POST",{camelCaseTypes:this.camel,pluralTypes:this.plural}),{headers:i,params:l,paramsSerializer:e=>s.query(e)});return s.deserialise(p)}catch(e){throw s.error(e)}}async delete(e,a,t={}){try{const i=r(this.headers,t.headers),l=r({},t.params),[h,o]=s.splitModel(e,{resourceCase:this.resCase,pluralModel:this.plural});let p,c;Array.isArray(a)?(p=o,c=a.map(e=>({id:e}))):(p="".concat(o,"/").concat(a),c={id:a});const{data:d}=await this.axios.delete(p,{data:s.serialise(h,c,"DELETE",{camelCaseTypes:this.camel,pluralTypes:this.plural}),headers:i,params:l,paramsSerializer:e=>s.query(e)});return d}catch(e){throw s.error(e)}}async self(e={}){try{const s=r(this.headers,e.headers),a=r(e.params,{filter:{self:!0}});return(await this.get("users",r({headers:s},{params:a}))).data[0]}catch(e){throw s.error(e)}}async request({body:e,method:a,params:t,type:i,url:l,headers:h}){try{var o;a=(null===(o=a)||void 0===o?void 0:o.toUpperCase())||"GET";const{data:p}=await this.axios.request({method:a,url:l,data:["GET","DELETE"].includes(a)?void 0:s.serialise(i,e,a,{camelCaseTypes:this.camel,pluralTypes:this.plural}),headers:r(this.headers,h),params:t,paramsSerializer:e=>s.query(e)});return s.deserialise(p)}catch(e){throw s.error(e)}}}; |
{ | ||
"version": "9.1.11", | ||
"version": "10.0.0-alpha.0", | ||
"name": "kitsu", | ||
@@ -50,3 +50,4 @@ "description": "A simple, lightweight & framework agnostic JSON:API client using Axios", | ||
"axios": "^0.19.0", | ||
"kitsu-core": "^9.1.11", | ||
"kitsu-core": "^10.0.0-alpha.0", | ||
"merge-options": "^2.0.0", | ||
"pluralize": "^8.0.0" | ||
@@ -66,3 +67,3 @@ }, | ||
], | ||
"gitHead": "edb7e07755b5d4a78509cb539d03f18ee3a2f5ca", | ||
"gitHead": "0c6649cae050cc7a2d0205139f3549996be372ff", | ||
"devDependencies": { | ||
@@ -69,0 +70,0 @@ "@size-limit/preset-small-lib": "~4.5.0" |
@@ -25,3 +25,3 @@ <h1 align=center>Kitsu</h1> | ||
<p align=center><a href=https://github.com/wopian/kitsu/blob/master/packages/kitsu/MIGRATING.md>Migration guide</a> for v9 & previous major releases</p> | ||
<p align=center><a href=https://github.com/wopian/kitsu/blob/master/packages/kitsu/MIGRATING.md>Migration guide</a> for v10 & previous major releases</p> | ||
@@ -39,7 +39,8 @@ # | ||
| Package | Package<br> Size\* | Node | Chrome | Firefox | Safari | Edge | | ||
| ------: | :----------------: | :--: | :----: | :-----: | :----: | :--: | | ||
| `kitsu` | ≤ 8.2 kb | 10+ | 69+ | 68+ | 12+ | 18+ | | ||
| Package | Package<br> Size\* | ESM Size† | Node | Chrome | Firefox | Safari | Edge | | ||
| ------: | :----------------: | :-------: | :--: | :----: | :-----: | :----: | :--: | | ||
| `kitsu` | ≤ 8.6 kb | ≤ 8.4 KB | 10+ | 69+ | 68+ | 12+ | 18+ | | ||
\* Including all dependencies & minified with brotli | ||
† EcmaScript Modules package size\* | ||
@@ -214,3 +215,3 @@ ## Response Comparison | ||
[packages/kitsu/src/index.js:30-464](https://github.com/wopian/kitsu/blob/3fcd88441936dfcec441faf3c5903c04c6c0c0cc/packages/kitsu/src/index.js#L30-L464 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:31-482](https://github.com/wopian/kitsu/blob/fcd06d9b5338ab28637a564c3b770a96750ad00a/packages/kitsu/src/index.js#L31-L482 "Source code on GitHub") | ||
@@ -262,3 +263,3 @@ Creates a new `kitsu` instance | ||
[packages/kitsu/src/index.js:52-53](https://github.com/wopian/kitsu/blob/3fcd88441936dfcec441faf3c5903c04c6c0c0cc/packages/kitsu/src/index.js#L52-L53 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:53-54](https://github.com/wopian/kitsu/blob/fcd06d9b5338ab28637a564c3b770a96750ad00a/packages/kitsu/src/index.js#L53-L54 "Source code on GitHub") | ||
@@ -285,3 +286,3 @@ - **See: <https://www.npmjs.com/package/pluralize> for documentation | ||
[packages/kitsu/src/index.js:67-67](https://github.com/wopian/kitsu/blob/3fcd88441936dfcec441faf3c5903c04c6c0c0cc/packages/kitsu/src/index.js#L67-L67 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:68-68](https://github.com/wopian/kitsu/blob/fcd06d9b5338ab28637a564c3b770a96750ad00a/packages/kitsu/src/index.js#L68-L68 "Source code on GitHub") | ||
@@ -317,3 +318,3 @@ Get the current headers or add additional headers | ||
[packages/kitsu/src/index.js:112-112](https://github.com/wopian/kitsu/blob/3fcd88441936dfcec441faf3c5903c04c6c0c0cc/packages/kitsu/src/index.js#L112-L112 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:113-113](https://github.com/wopian/kitsu/blob/fcd06d9b5338ab28637a564c3b770a96750ad00a/packages/kitsu/src/index.js#L113-L113 "Source code on GitHub") | ||
@@ -369,3 +370,3 @@ - **See: <https://github.com/axios/axios#interceptors> for documentation | ||
[packages/kitsu/src/index.js:189-208](https://github.com/wopian/kitsu/blob/3fcd88441936dfcec441faf3c5903c04c6c0c0cc/packages/kitsu/src/index.js#L189-L208 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:191-211](https://github.com/wopian/kitsu/blob/fcd06d9b5338ab28637a564c3b770a96750ad00a/packages/kitsu/src/index.js#L191-L211 "Source code on GitHub") | ||
@@ -377,15 +378,16 @@ Fetch resources (alias `fetch`) | ||
- `model` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Model to fetch data from | ||
- `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** JSON-API request queries. Any JSON:API query parameter not mentioned below is supported out of the box. (optional, default `{}`) | ||
- `params.page` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** [JSON:API Pagination](http://jsonapi.org/format/#fetching-pagination). All pagination strategies are supported, even if they are not listed below. | ||
- `params.page.limit` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Number of resources to return in request (Offset-based) - **Note:** For Kitsu.io, max is `20` except on `libraryEntries` which has a max of `500` | ||
- `params.page.offset` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Number of resources to offset the dataset by (Offset-based) | ||
- `params.page.number` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Page of resources to return in request (Page-based) - **Note:** Not supported on Kitsu.io | ||
- `params.page.size` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Number of resources to return in request (Page-based and cursor-based) - **Note:** Not supported on Kitsu.io | ||
- `params.page.before` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Get the previous page of resources (Cursor-based) - **Note:** Not Supported on Kitsu.io | ||
- `params.page.after` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Get the next page of resources (Cursor-based) - **Note:** Not Supported on Kitsu.io | ||
- `params.fields` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Return a sparse fieldset with only the included attributes/relationships - [JSON:API Sparse Fieldsets](http://jsonapi.org/format/#fetching-sparse-fieldsets) | ||
- `params.filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Filter dataset by attribute values - [JSON:API Filtering](http://jsonapi.org/format/#fetching-filtering) | ||
- `params.sort` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Sort dataset by one or more comma separated attributes (prepend `-` for descending order) - [JSON:API Sorting](http://jsonapi.org/format/#fetching-sorting) | ||
- `params.include` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Include relationship data - [JSON:API Includes](http://jsonapi.org/format/#fetching-includes) | ||
- `headers` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional headers to send with the request (optional, default `{}`) | ||
- `config` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional configuration (optional, default `{}`) | ||
- `config.headers` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional headers to send with the request | ||
- `config.params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** JSON:API request queries. JSON:API query parameters not listed are supported | ||
- `config.params.fields` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Return a sparse fieldset with only the included attributes/relationships - [JSON:API Sparse Fieldsets](http://jsonapi.org/format/#fetching-sparse-fieldsets) | ||
- `config.params.filter` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Filter dataset by attribute values - [JSON:API Filtering](http://jsonapi.org/format/#fetching-filtering) | ||
- `config.params.include` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Include relationship data - [JSON:API Includes](http://jsonapi.org/format/#fetching-includes) | ||
- `config.params.sort` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Sort dataset by one or more comma separated attributes (prepend `-` for descending order) - [JSON:API Sorting](http://jsonapi.org/format/#fetching-sorting) | ||
- `config.params.page` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** [JSON:API Pagination](http://jsonapi.org/format/#fetching-pagination). All pagination strategies are supported, even if they are not listed below. | ||
- `config.params.page.limit` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Number of resources to return in request (Offset-based) - **Note:** For Kitsu.io, max is `20` except on `libraryEntries` which has a max of `500` | ||
- `config.params.page.offset` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Number of resources to offset the dataset by (Offset-based) | ||
- `config.params.page.number` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Page of resources to return in request (Page-based) - **Note:** Not supported on Kitsu.io | ||
- `config.params.page.size` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Number of resources to return in request (Page-based and cursor-based) - **Note:** Not supported on Kitsu.io | ||
- `config.params.page.before` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Get the previous page of resources (Cursor-based) - **Note:** Not Supported on Kitsu.io | ||
- `config.params.page.after` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Get the next page of resources (Cursor-based) - **Note:** Not Supported on Kitsu.io | ||
@@ -487,3 +489,3 @@ ##### Examples | ||
[packages/kitsu/src/index.js:241-262](https://github.com/wopian/kitsu/blob/3fcd88441936dfcec441faf3c5903c04c6c0c0cc/packages/kitsu/src/index.js#L241-L262 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:246-273](https://github.com/wopian/kitsu/blob/fcd06d9b5338ab28637a564c3b770a96750ad00a/packages/kitsu/src/index.js#L246-L273 "Source code on GitHub") | ||
@@ -496,3 +498,5 @@ Update a resource (alias `update`) | ||
- `body` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>)** Data to send in the request | ||
- `headers` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional headers to send with the request (optional, default `{}`) | ||
- `config` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional configuration (optional, default `{}`) | ||
- `config.params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** JSON:API request queries. See [#get](#get) for documentation | ||
- `config.headers` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional headers to send with the request | ||
@@ -552,3 +556,3 @@ ##### Examples | ||
[packages/kitsu/src/index.js:290-309](https://github.com/wopian/kitsu/blob/3fcd88441936dfcec441faf3c5903c04c6c0c0cc/packages/kitsu/src/index.js#L290-L309 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:303-328](https://github.com/wopian/kitsu/blob/fcd06d9b5338ab28637a564c3b770a96750ad00a/packages/kitsu/src/index.js#L303-L328 "Source code on GitHub") | ||
@@ -561,3 +565,5 @@ Create a new resource (alias `create`) | ||
- `body` **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>)** Data to send in the request | ||
- `headers` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional headers to send with the request (optional, default `{}`) | ||
- `config` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional configuration (optional, default `{}`) | ||
- `config.params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** JSON:API request queries. See [#get](#get) for documentation | ||
- `config.headers` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional headers to send with the request | ||
@@ -597,3 +603,3 @@ ##### Examples | ||
[packages/kitsu/src/index.js:324-353](https://github.com/wopian/kitsu/blob/3fcd88441936dfcec441faf3c5903c04c6c0c0cc/packages/kitsu/src/index.js#L324-L353 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:345-378](https://github.com/wopian/kitsu/blob/fcd06d9b5338ab28637a564c3b770a96750ad00a/packages/kitsu/src/index.js#L345-L378 "Source code on GitHub") | ||
@@ -606,3 +612,5 @@ Remove a resource (alias `remove`) | ||
- `id` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) \| [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) \| [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)>)** Resource ID to remove. Pass an array of IDs to delete multiple resources (Bulk Extension) | ||
- `headers` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional headers to send with the request (optional, default `{}`) | ||
- `config` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional configuration (optional, default `{}`) | ||
- `config.params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** JSON:API request queries. See [#get](#get) for documentation | ||
- `config.headers` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional headers to send with the request | ||
@@ -629,3 +637,3 @@ ##### Examples | ||
[packages/kitsu/src/index.js:375-382](https://github.com/wopian/kitsu/blob/3fcd88441936dfcec441faf3c5903c04c6c0c0cc/packages/kitsu/src/index.js#L375-L382 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:399-408](https://github.com/wopian/kitsu/blob/fcd06d9b5338ab28637a564c3b770a96750ad00a/packages/kitsu/src/index.js#L399-L408 "Source code on GitHub") | ||
@@ -638,6 +646,5 @@ Get the authenticated user's data | ||
- `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** JSON-API request queries (optional, default `{}`) | ||
- `params.fields` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Return a sparse fieldset with only the included attributes/relationships - [JSON:API Sparse Fieldsets](http://jsonapi.org/format/#fetching-sparse-fieldsets) | ||
- `params.include` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Include relationship data - [JSON:API Includes](http://jsonapi.org/format/#fetching-includes) | ||
- `headers` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional headers to send with the request (optional, default `{}`) | ||
- `config` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional configuration (optional, default `{}`) | ||
- `config.params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** JSON:API request queries. See [#get](#get) for documentation | ||
- `config.headers` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional headers to send with the request | ||
@@ -668,3 +675,3 @@ ##### Examples | ||
[packages/kitsu/src/index.js:443-463](https://github.com/wopian/kitsu/blob/3fcd88441936dfcec441faf3c5903c04c6c0c0cc/packages/kitsu/src/index.js#L443-L463 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:462-481](https://github.com/wopian/kitsu/blob/fcd06d9b5338ab28637a564c3b770a96750ad00a/packages/kitsu/src/index.js#L462-L481 "Source code on GitHub") | ||
@@ -680,13 +687,6 @@ Send arbitrary requests | ||
- `config.method` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Request method - `GET`, `PATCH`, `POST` or `DELETE` (defaults to `GET`, case-insensitive) | ||
- `config.params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** JSON-API request queries. Any JSON:API query parameter not mentioned below is supported out of the box. | ||
- `config.params.page` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** [JSON:API Pagination](http://jsonapi.org/format/#fetching-pagination). All pagination strategies are supported, even if they are not listed below. | ||
- `config.params.page.limit` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Number of resources to return in request (Offset-based) - **Note:** For Kitsu.io, max is `20` except on `libraryEntries` which has a max of `500` | ||
- `config.params.page.offset` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Number of resources to offset the dataset by (Offset-based) | ||
- `config.params.page.number` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Page of resources to return in request (Page-based) - **Note:** Not supported on Kitsu.io | ||
- `config.params.page.size` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)?** Number of resources to return in request (Page-based and cursor-based) - **Note:** Not supported on Kitsu.io | ||
- `config.params.page.before` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Get the previous page of resources (Cursor-based) - **Note:** Not Supported on Kitsu.io | ||
- `config.params.page.after` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Get the next page of resources (Cursor-based) - **Note:** Not Supported on Kitsu.io | ||
- `config.params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** JSON:API request queries. See [#get](#get) for documentation | ||
- `config.type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The resource type | ||
- `config.url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The URL path of the resource | ||
- `headers` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional headers to send with the request (optional, default `{}`) | ||
- `config.headers` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional headers to send with the request | ||
@@ -693,0 +693,0 @@ ##### Examples |
@@ -45,19 +45,31 @@ /** | ||
axios: import("axios").AxiosInstance; | ||
fetch: (model: string, params?: { | ||
page: { | ||
limit: number; | ||
offset: number; | ||
number: number; | ||
size: number; | ||
before: string; | ||
after: string; | ||
fetch: (model: string, config?: { | ||
headers: any; | ||
params: { | ||
fields: any; | ||
filter: any; | ||
include: string; | ||
sort: string; | ||
page: { | ||
limit: number; | ||
offset: number; | ||
number: number; | ||
size: number; | ||
before: string; | ||
after: string; | ||
}; | ||
}; | ||
fields: any; | ||
filter: any; | ||
sort: string; | ||
include: string; | ||
}, headers?: any) => any; | ||
update: (model: string, body: any | any[], headers?: any) => any | any[]; | ||
create: (model: string, body: any | any[], headers?: any) => any | any[]; | ||
remove: (model: string, id: string | number | number[], headers?: any) => any | any[]; | ||
}) => any; | ||
update: (model: string, body: any | any[], config?: { | ||
params: any; | ||
headers: any; | ||
}) => any | any[]; | ||
create: (model: string, body: any | any[], config?: { | ||
params: any; | ||
headers: any; | ||
}) => any | any[]; | ||
remove: (model: string, id: string | number | number[], config?: { | ||
params: any; | ||
headers: any; | ||
}) => any | any[]; | ||
/** | ||
@@ -103,15 +115,16 @@ * Axios Interceptors (alias of `axios.interceptors`) | ||
* @param {string} model Model to fetch data from | ||
* @param {Object} [params] JSON-API request queries. Any JSON:API query parameter not mentioned below is supported out of the box. | ||
* @param {Object} [params.page] [JSON:API Pagination](http://jsonapi.org/format/#fetching-pagination). All pagination strategies are supported, even if they are not listed below. | ||
* @param {number} [params.page.limit] Number of resources to return in request (Offset-based) - **Note:** For Kitsu.io, max is `20` except on `libraryEntries` which has a max of `500` | ||
* @param {number} [params.page.offset] Number of resources to offset the dataset by (Offset-based) | ||
* @param {number} [params.page.number] Page of resources to return in request (Page-based) - **Note:** Not supported on Kitsu.io | ||
* @param {number} [params.page.size] Number of resources to return in request (Page-based and cursor-based) - **Note:** Not supported on Kitsu.io | ||
* @param {string} [params.page.before] Get the previous page of resources (Cursor-based) - **Note:** Not Supported on Kitsu.io | ||
* @param {string} [params.page.after] Get the next page of resources (Cursor-based) - **Note:** Not Supported on Kitsu.io | ||
* @param {Object} [params.fields] Return a sparse fieldset with only the included attributes/relationships - [JSON:API Sparse Fieldsets](http://jsonapi.org/format/#fetching-sparse-fieldsets) | ||
* @param {Object} [params.filter] Filter dataset by attribute values - [JSON:API Filtering](http://jsonapi.org/format/#fetching-filtering) | ||
* @param {string} [params.sort] Sort dataset by one or more comma separated attributes (prepend `-` for descending order) - [JSON:API Sorting](http://jsonapi.org/format/#fetching-sorting) | ||
* @param {string} [params.include] Include relationship data - [JSON:API Includes](http://jsonapi.org/format/#fetching-includes) | ||
* @param {Object} [headers] Additional headers to send with the request | ||
* @param {Object} [config] Additional configuration | ||
* @param {Object} [config.headers] Additional headers to send with the request | ||
* @param {Object} [config.params] JSON:API request queries. JSON:API query parameters not listed are supported | ||
* @param {Object} [config.params.fields] Return a sparse fieldset with only the included attributes/relationships - [JSON:API Sparse Fieldsets](http://jsonapi.org/format/#fetching-sparse-fieldsets) | ||
* @param {Object} [config.params.filter] Filter dataset by attribute values - [JSON:API Filtering](http://jsonapi.org/format/#fetching-filtering) | ||
* @param {string} [config.params.include] Include relationship data - [JSON:API Includes](http://jsonapi.org/format/#fetching-includes) | ||
* @param {string} [config.params.sort] Sort dataset by one or more comma separated attributes (prepend `-` for descending order) - [JSON:API Sorting](http://jsonapi.org/format/#fetching-sorting) | ||
* @param {Object} [config.params.page] [JSON:API Pagination](http://jsonapi.org/format/#fetching-pagination). All pagination strategies are supported, even if they are not listed below. | ||
* @param {number} [config.params.page.limit] Number of resources to return in request (Offset-based) - **Note:** For Kitsu.io, max is `20` except on `libraryEntries` which has a max of `500` | ||
* @param {number} [config.params.page.offset] Number of resources to offset the dataset by (Offset-based) | ||
* @param {number} [config.params.page.number] Page of resources to return in request (Page-based) - **Note:** Not supported on Kitsu.io | ||
* @param {number} [config.params.page.size] Number of resources to return in request (Page-based and cursor-based) - **Note:** Not supported on Kitsu.io | ||
* @param {string} [config.params.page.before] Get the previous page of resources (Cursor-based) - **Note:** Not Supported on Kitsu.io | ||
* @param {string} [config.params.page.after] Get the next page of resources (Cursor-based) - **Note:** Not Supported on Kitsu.io | ||
* @returns {Object} JSON-parsed response | ||
@@ -173,16 +186,19 @@ * @example <caption>Getting a resource with JSON:API parameters</caption> | ||
*/ | ||
get(model: string, params?: { | ||
page: { | ||
limit: number; | ||
offset: number; | ||
number: number; | ||
size: number; | ||
before: string; | ||
after: string; | ||
get(model: string, config?: { | ||
headers: any; | ||
params: { | ||
fields: any; | ||
filter: any; | ||
include: string; | ||
sort: string; | ||
page: { | ||
limit: number; | ||
offset: number; | ||
number: number; | ||
size: number; | ||
before: string; | ||
after: string; | ||
}; | ||
}; | ||
fields: any; | ||
filter: any; | ||
sort: string; | ||
include: string; | ||
}, headers?: any): any; | ||
}): any; | ||
/** | ||
@@ -194,3 +210,5 @@ * Update a resource (alias `update`) | ||
* @param {Object|Object[]} body Data to send in the request | ||
* @param {Object} [headers] Additional headers to send with the request | ||
* @param {Object} [config] Additional configuration | ||
* @param {Object} [config.params] JSON:API request queries. See [#get](#get) for documentation | ||
* @param {Object} [config.headers] Additional headers to send with the request | ||
* @returns {Object|Object[]} JSON-parsed response | ||
@@ -220,3 +238,6 @@ * @example <caption>Update a resource</caption> | ||
*/ | ||
patch(model: string, body: any | any[], headers?: any): any | any[]; | ||
patch(model: string, body: any | any[], config?: { | ||
params: any; | ||
headers: any; | ||
}): any | any[]; | ||
/** | ||
@@ -228,3 +249,5 @@ * Create a new resource (alias `create`) | ||
* @param {Object|Object[]} body Data to send in the request | ||
* @param {Object} [headers] Additional headers to send with the request | ||
* @param {Object} [config] Additional configuration | ||
* @param {Object} [config.params] JSON:API request queries. See [#get](#get) for documentation | ||
* @param {Object} [config.headers] Additional headers to send with the request | ||
* @returns {Object|Object[]} JSON-parsed response | ||
@@ -249,3 +272,6 @@ * @example <caption>Create a post on a user's profile feed</caption> | ||
*/ | ||
post(model: string, body: any | any[], headers?: any): any | any[]; | ||
post(model: string, body: any | any[], config?: { | ||
params: any; | ||
headers: any; | ||
}): any | any[]; | ||
/** | ||
@@ -257,3 +283,5 @@ * Remove a resource (alias `remove`) | ||
* @param {string|number|number[]} id Resource ID to remove. Pass an array of IDs to delete multiple resources (Bulk Extension) | ||
* @param {Object} [headers] Additional headers to send with the request | ||
* @param {Object} [config] Additional configuration | ||
* @param {Object} [config.params] JSON:API request queries. See [#get](#get) for documentation | ||
* @param {Object} [config.headers] Additional headers to send with the request | ||
* @returns {Object|Object[]} JSON-parsed response | ||
@@ -265,3 +293,6 @@ * @example <caption>Remove a single resource</caption> | ||
*/ | ||
delete(model: string, id: string | number | number[], headers?: any): any | any[]; | ||
delete(model: string, id: string | number | number[], config?: { | ||
params: any; | ||
headers: any; | ||
}): any | any[]; | ||
/** | ||
@@ -273,6 +304,5 @@ * Get the authenticated user's data | ||
* @memberof Kitsu | ||
* @param {Object} [params] JSON-API request queries | ||
* @param {Object} [params.fields] Return a sparse fieldset with only the included attributes/relationships - [JSON:API Sparse Fieldsets](http://jsonapi.org/format/#fetching-sparse-fieldsets) | ||
* @param {string} [params.include] Include relationship data - [JSON:API Includes](http://jsonapi.org/format/#fetching-includes) | ||
* @param {Object} [headers] Additional headers to send with the request | ||
* @param {Object} [config] Additional configuration | ||
* @param {Object} [config.params] JSON:API request queries. See [#get](#get) for documentation | ||
* @param {Object} [config.headers] Additional headers to send with the request | ||
* @returns {Object} JSON-parsed response | ||
@@ -288,6 +318,6 @@ * @example <caption>Get the authenticated user's resource</caption> | ||
*/ | ||
self(params?: { | ||
fields: any; | ||
include: string; | ||
}, headers?: any): any; | ||
self(config?: { | ||
params: any; | ||
headers: any; | ||
}): any; | ||
/** | ||
@@ -304,11 +334,4 @@ * Send arbitrary requests | ||
* @param {string} [config.method] Request method - `GET`, `PATCH`, `POST` or `DELETE` (defaults to `GET`, case-insensitive) | ||
* @param {Object} [config.params] JSON-API request queries. Any JSON:API query parameter not mentioned below is supported out of the box. | ||
* @param {Object} [config.params.page] [JSON:API Pagination](http://jsonapi.org/format/#fetching-pagination). All pagination strategies are supported, even if they are not listed below. | ||
* @param {number} [config.params.page.limit] Number of resources to return in request (Offset-based) - **Note:** For Kitsu.io, max is `20` except on `libraryEntries` which has a max of `500` | ||
* @param {number} [config.params.page.offset] Number of resources to offset the dataset by (Offset-based) | ||
* @param {number} [config.params.page.number] Page of resources to return in request (Page-based) - **Note:** Not supported on Kitsu.io | ||
* @param {number} [config.params.page.size] Number of resources to return in request (Page-based and cursor-based) - **Note:** Not supported on Kitsu.io | ||
* @param {string} [config.params.page.before] Get the previous page of resources (Cursor-based) - **Note:** Not Supported on Kitsu.io | ||
* @param {string} [config.params.page.after] Get the next page of resources (Cursor-based) - **Note:** Not Supported on Kitsu.io | ||
* @param {Object} [headers] Additional headers to send with the request | ||
* @param {Object} [config.params] JSON:API request queries. See [#get](#get) for documentation | ||
* @param {Object} [config.headers] Additional headers to send with the request | ||
* @returns {Object} JSON-parsed response | ||
@@ -353,3 +376,3 @@ * @example <caption>Raw GET request</caption> | ||
*/ | ||
request({ body, method, params, type, url }?: { | ||
request({ body, method, params, type, url, headers }?: { | ||
url: string; | ||
@@ -359,13 +382,5 @@ type: string; | ||
method: string; | ||
params: { | ||
page: { | ||
limit: number; | ||
offset: number; | ||
number: number; | ||
size: number; | ||
before: string; | ||
after: string; | ||
}; | ||
}; | ||
}, headers?: any): any; | ||
params: any; | ||
headers: any; | ||
}): any; | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
64430
395
4
1
2
+ Addedmerge-options@^2.0.0
+ Addedis-plain-obj@2.1.0(transitive)
+ Addedkitsu-core@10.1.5(transitive)
+ Addedmerge-options@2.0.0(transitive)
- Removedkitsu-core@9.1.29(transitive)
Updatedkitsu-core@^10.0.0-alpha.0