Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kitsu

Package Overview
Dependencies
Maintainers
1
Versions
172
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kitsu - npm Package Compare versions

Comparing version 10.0.0-alpha.13 to 10.0.0-alpha.14

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [10.0.0-alpha.14](https://github.com/wopian/kitsu/compare/v10.0.0-alpha.13...v10.0.0-alpha.14) (2021-08-16)
### Features
* return header object when present ([b3e2624](https://github.com/wopian/kitsu/commit/b3e2624a1e5969e606fc50daa68fdd44ff90abb2))
# [10.0.0-alpha.13](https://github.com/wopian/kitsu/compare/v10.0.0-alpha.12...v10.0.0-alpha.13) (2021-06-07)

@@ -8,0 +19,0 @@

2

dist/index.js

@@ -1,1 +0,1 @@

"use strict";var e=require("kitsu-core"),a=require("axios"),s=require("merge-options"),r=require("pluralize");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=t(a),l=t(s),h=t(r);module.exports=class{constructor(a={}){!1===a.camelCaseTypes?this.camel=e=>e:this.camel=e.camel,"none"===a.resourceCase?this.resCase=e=>e:"snake"===a.resourceCase?this.resCase=e.snake:this.resCase=e.kebab,!1===a.pluralize?this.plural=e=>e:this.plural=h.default,this.headers=l.default({Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json"},a.headers),this.axios=i.default.create(l.default({baseURL:a.baseURL||"https://kitsu.io/api/edge",timeout:a.timeout||3e4},a.axiosOptions)),this.fetch=this.get,this.update=this.patch,this.create=this.post,this.remove=this.delete,this.interceptors=this.axios.interceptors}async get(a,s={}){try{const r=l.default(this.headers,s.headers),t=l.default({},s.params),[i,h,p,d]=a.split("/");let u=this.plural(this.resCase(i));h&&(u+=`/${this.resCase(h)}`),p&&(u+=`/${this.resCase(p)}`),d&&(u+=`/${this.resCase(d)}`);const{data:o}=await this.axios.get(u,{headers:r,params:t,paramsSerializer:a=>e.query(a)});return e.deserialise(o)}catch(a){throw e.error(a)}}async patch(a,s,r={}){try{const t=l.default(this.headers,r.headers),i=l.default({},r.params),[h,p]=e.splitModel(a,{resourceCase:this.resCase,pluralModel:this.plural}),d=e.serialise(h,s,"PATCH",{camelCaseTypes:this.camel,pluralTypes:this.plural}),u=null!=s&&s.id?`${p}/${s.id}`:p,{data:o}=await this.axios.patch(u,d,{headers:t,params:i,paramsSerializer:a=>e.query(a)});return e.deserialise(o)}catch(a){throw e.error(a)}}async post(a,s,r={}){try{const t=l.default(this.headers,r.headers),i=l.default({},r.params),[h,p]=e.splitModel(a,{resourceCase:this.resCase,pluralModel:this.plural}),{data:d}=await this.axios.post(p,e.serialise(h,s,"POST",{camelCaseTypes:this.camel,pluralTypes:this.plural}),{headers:t,params:i,paramsSerializer:a=>e.query(a)});return e.deserialise(d)}catch(a){throw e.error(a)}}async delete(a,s,r={}){try{const t=l.default(this.headers,r.headers),i=l.default({},r.params),[h,p]=e.splitModel(a,{resourceCase:this.resCase,pluralModel:this.plural});let d,u;Array.isArray(s)?(d=p,u=s.map((e=>({id:e})))):(d=`${p}/${s}`,u={id:s});const{data:o}=await this.axios.delete(d,{data:e.serialise(h,u,"DELETE",{camelCaseTypes:this.camel,pluralTypes:this.plural}),headers:t,params:i,paramsSerializer:a=>e.query(a)});return o}catch(a){throw e.error(a)}}async self(a={}){try{const e=l.default(this.headers,a.headers),s=l.default(a.params,{filter:{self:!0}});return(await this.get("users",l.default({headers:e},{params:s}))).data[0]}catch(a){throw e.error(a)}}async request({body:a,method:s,params:r,type:t,url:i,headers:h}){try{var p;s=(null===(p=s)||void 0===p?void 0:p.toUpperCase())||"GET";const{data:d}=await this.axios.request({method:s,url:i,data:["GET","DELETE"].includes(s)?void 0:e.serialise(t,a,s,{camelCaseTypes:this.camel,pluralTypes:this.plural}),headers:l.default(this.headers,h),params:r,paramsSerializer:a=>e.query(a)});return e.deserialise(d)}catch(a){throw e.error(a)}}};
"use strict";var e=require("kitsu-core"),a=require("axios"),s=require("merge-options"),r=require("pluralize");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var i=t(a),l=t(s),d=t(r);module.exports=class{constructor(a={}){!1===a.camelCaseTypes?this.camel=e=>e:this.camel=e.camel,"none"===a.resourceCase?this.resCase=e=>e:"snake"===a.resourceCase?this.resCase=e.snake:this.resCase=e.kebab,!1===a.pluralize?this.plural=e=>e:this.plural=d.default,this.headers=l.default({Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json"},a.headers),this.axios=i.default.create(l.default({baseURL:a.baseURL||"https://kitsu.io/api/edge",timeout:a.timeout||3e4},a.axiosOptions)),this.fetch=this.get,this.update=this.patch,this.create=this.post,this.remove=this.delete,this.interceptors=this.axios.interceptors}async get(a,s={}){try{const r=l.default(this.headers,s.headers),t=l.default({},s.params),[i,d,h,u]=a.split("/");let p=this.plural(this.resCase(i));d&&(p+=`/${this.resCase(d)}`),h&&(p+=`/${this.resCase(h)}`),u&&(p+=`/${this.resCase(u)}`);const{data:o,headers:c}=await this.axios.get(p,{headers:r,params:t,paramsSerializer:a=>e.query(a)});return c?l.default(e.deserialise(o),{headers:c}):e.deserialise(o)}catch(a){throw e.error(a)}}async patch(a,s,r={}){try{const t=l.default(this.headers,r.headers),i=l.default({},r.params),[d,h]=e.splitModel(a,{resourceCase:this.resCase,pluralModel:this.plural}),u=e.serialise(d,s,"PATCH",{camelCaseTypes:this.camel,pluralTypes:this.plural}),p=null!=s&&s.id?`${h}/${s.id}`:h,{data:o,headers:c}=await this.axios.patch(p,u,{headers:t,params:i,paramsSerializer:a=>e.query(a)});return c?l.default(e.deserialise(o),{headers:c}):e.deserialise(o)}catch(a){throw e.error(a)}}async post(a,s,r={}){try{const t=l.default(this.headers,r.headers),i=l.default({},r.params),[d,h]=e.splitModel(a,{resourceCase:this.resCase,pluralModel:this.plural}),{data:u,headers:p}=await this.axios.post(h,e.serialise(d,s,"POST",{camelCaseTypes:this.camel,pluralTypes:this.plural}),{headers:t,params:i,paramsSerializer:a=>e.query(a)});return p?l.default(e.deserialise(u),{headers:p}):e.deserialise(u)}catch(a){throw e.error(a)}}async delete(a,s,r={}){try{const t=l.default(this.headers,r.headers),i=l.default({},r.params),[d,h]=e.splitModel(a,{resourceCase:this.resCase,pluralModel:this.plural});let u,p;Array.isArray(s)?(u=h,p=s.map((e=>({id:e})))):(u=`${h}/${s}`,p={id:s});const{data:o,headers:c}=await this.axios.delete(u,{data:e.serialise(d,p,"DELETE",{camelCaseTypes:this.camel,pluralTypes:this.plural}),headers:t,params:i,paramsSerializer:a=>e.query(a)});return c?l.default(e.deserialise(o),{headers:c}):e.deserialise(o)}catch(a){throw e.error(a)}}async self(a={}){try{const e=l.default(this.headers,a.headers),s=l.default(a.params,{filter:{self:!0}}),r=await this.get("users",l.default({headers:e},{params:s}));return r.headers?l.default({data:r.data[0]},{headers:r.headers}):{data:r.data[0]}}catch(a){throw e.error(a)}}async request({body:a,method:s,params:r,type:t,url:i,headers:d}){try{var h;s=(null===(h=s)||void 0===h?void 0:h.toUpperCase())||"GET";const{data:u,headers:p}=await this.axios.request({method:s,url:i,data:["GET","DELETE"].includes(s)?void 0:e.serialise(t,a,s,{camelCaseTypes:this.camel,pluralTypes:this.plural}),headers:l.default(this.headers,d),params:r,paramsSerializer:a=>e.query(a)});return p?l.default(e.deserialise(u),{headers:p}):e.deserialise(u)}catch(a){throw e.error(a)}}};
{
"version": "10.0.0-alpha.13",
"version": "10.0.0-alpha.14",
"name": "kitsu",

@@ -53,3 +53,3 @@ "description": "A simple, lightweight & framework agnostic JSON:API client using Axios",

"axios": "^0.21.1",
"kitsu-core": "^10.0.0-alpha.13",
"kitsu-core": "^10.0.0-alpha.14",
"merge-options": "^3.0.0",

@@ -70,5 +70,5 @@ "pluralize": "^8.0.0"

],
"gitHead": "57c200fdfa6f50a594c10fc8f1d1124cb99b704b",
"gitHead": "5c9778d191d17d7c9790cfc6d0f4e983b4742a53",
"devDependencies": {
"@size-limit/preset-small-lib": "~4.11.0"
"@size-limit/preset-small-lib": "~5.0.0"
},

@@ -75,0 +75,0 @@ "exports": {

@@ -245,3 +245,3 @@ <h1 align=center>Kitsu</h1>

[packages/kitsu/src/index.js:31-513](https://github.com/wopian/kitsu/blob/521a395decb33e0e92ba75be73665a410f4127b9/packages/kitsu/src/index.js#L31-L513 "Source code on GitHub")
[packages/kitsu/src/index.js:31-513](https://github.com/wopian/kitsu/blob/b3e2624a1e5969e606fc50daa68fdd44ff90abb2/packages/kitsu/src/index.js#L31-L513 "Source code on GitHub")

@@ -291,3 +291,3 @@ Creates a new `kitsu` instance

[packages/kitsu/src/index.js:53-54](https://github.com/wopian/kitsu/blob/521a395decb33e0e92ba75be73665a410f4127b9/packages/kitsu/src/index.js#L53-L54 "Source code on GitHub")
[packages/kitsu/src/index.js:53-54](https://github.com/wopian/kitsu/blob/b3e2624a1e5969e606fc50daa68fdd44ff90abb2/packages/kitsu/src/index.js#L53-L54 "Source code on GitHub")

@@ -311,3 +311,3 @@ * **See**: <https://www.npmjs.com/package/pluralize> for documentation

[packages/kitsu/src/index.js:68-68](https://github.com/wopian/kitsu/blob/521a395decb33e0e92ba75be73665a410f4127b9/packages/kitsu/src/index.js#L68-L68 "Source code on GitHub")
[packages/kitsu/src/index.js:68-68](https://github.com/wopian/kitsu/blob/b3e2624a1e5969e606fc50daa68fdd44ff90abb2/packages/kitsu/src/index.js#L68-L68 "Source code on GitHub")

@@ -340,3 +340,3 @@ Get the current headers or add additional headers

[packages/kitsu/src/index.js:113-113](https://github.com/wopian/kitsu/blob/521a395decb33e0e92ba75be73665a410f4127b9/packages/kitsu/src/index.js#L113-L113 "Source code on GitHub")
[packages/kitsu/src/index.js:113-113](https://github.com/wopian/kitsu/blob/b3e2624a1e5969e606fc50daa68fdd44ff90abb2/packages/kitsu/src/index.js#L113-L113 "Source code on GitHub")

@@ -388,3 +388,3 @@ * **See**: <https://github.com/axios/axios#interceptors> for documentation

[packages/kitsu/src/index.js:210-238](https://github.com/wopian/kitsu/blob/521a395decb33e0e92ba75be73665a410f4127b9/packages/kitsu/src/index.js#L210-L238 "Source code on GitHub")
[packages/kitsu/src/index.js:210-238](https://github.com/wopian/kitsu/blob/b3e2624a1e5969e606fc50daa68fdd44ff90abb2/packages/kitsu/src/index.js#L210-L238 "Source code on GitHub")

@@ -525,3 +525,3 @@ Fetch resources (alias `fetch`)

[packages/kitsu/src/index.js:273-300](https://github.com/wopian/kitsu/blob/521a395decb33e0e92ba75be73665a410f4127b9/packages/kitsu/src/index.js#L273-L300 "Source code on GitHub")
[packages/kitsu/src/index.js:273-300](https://github.com/wopian/kitsu/blob/b3e2624a1e5969e606fc50daa68fdd44ff90abb2/packages/kitsu/src/index.js#L273-L300 "Source code on GitHub")

@@ -587,3 +587,3 @@ Update a resource (alias `update`)

[packages/kitsu/src/index.js:330-355](https://github.com/wopian/kitsu/blob/521a395decb33e0e92ba75be73665a410f4127b9/packages/kitsu/src/index.js#L330-L355 "Source code on GitHub")
[packages/kitsu/src/index.js:330-355](https://github.com/wopian/kitsu/blob/b3e2624a1e5969e606fc50daa68fdd44ff90abb2/packages/kitsu/src/index.js#L330-L355 "Source code on GitHub")

@@ -632,3 +632,3 @@ Create a new resource (alias `create`)

[packages/kitsu/src/index.js:372-405](https://github.com/wopian/kitsu/blob/521a395decb33e0e92ba75be73665a410f4127b9/packages/kitsu/src/index.js#L372-L405 "Source code on GitHub")
[packages/kitsu/src/index.js:372-405](https://github.com/wopian/kitsu/blob/b3e2624a1e5969e606fc50daa68fdd44ff90abb2/packages/kitsu/src/index.js#L372-L405 "Source code on GitHub")

@@ -664,3 +664,3 @@ Remove a resource (alias `remove`)

[packages/kitsu/src/index.js:428-437](https://github.com/wopian/kitsu/blob/521a395decb33e0e92ba75be73665a410f4127b9/packages/kitsu/src/index.js#L428-L437 "Source code on GitHub")
[packages/kitsu/src/index.js:428-437](https://github.com/wopian/kitsu/blob/b3e2624a1e5969e606fc50daa68fdd44ff90abb2/packages/kitsu/src/index.js#L428-L437 "Source code on GitHub")

@@ -702,3 +702,3 @@ Get the authenticated user's data

[packages/kitsu/src/index.js:491-512](https://github.com/wopian/kitsu/blob/521a395decb33e0e92ba75be73665a410f4127b9/packages/kitsu/src/index.js#L491-L512 "Source code on GitHub")
[packages/kitsu/src/index.js:491-512](https://github.com/wopian/kitsu/blob/b3e2624a1e5969e606fc50daa68fdd44ff90abb2/packages/kitsu/src/index.js#L491-L512 "Source code on GitHub")

@@ -705,0 +705,0 @@ Send arbitrary requests

@@ -0,0 +0,0 @@ /**

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc