Comparing version 10.0.2 to 10.0.3
@@ -6,2 +6,10 @@ # Change Log | ||
## [10.0.3](https://github.com/wopian/kitsu/compare/v10.0.2...v10.0.3) (2022-10-30) | ||
**Note:** Version bump only for package kitsu | ||
## [10.0.2](https://github.com/wopian/kitsu/compare/v10.0.1...v10.0.2) (2022-08-17) | ||
@@ -8,0 +16,0 @@ |
@@ -17,4 +17,7 @@ 'use strict'; | ||
if (options.resourceCase === 'none') this.resCase = s => s;else if (options.resourceCase === 'snake') this.resCase = kitsuCore.snake;else this.resCase = kitsuCore.kebab; | ||
if (options.pluralize === false) this.plural = s => s;else this.plural = pluralise__default["default"]; | ||
this.headers = { ...{ | ||
this.headers = { | ||
...{ | ||
Accept: 'application/vnd.api+json', | ||
@@ -25,3 +28,4 @@ 'Content-Type': 'application/vnd.api+json' | ||
}; | ||
this.axios = axios__default["default"].create({ ...{ | ||
this.axios = axios__default["default"].create({ | ||
...{ | ||
baseURL: options.baseURL || 'https://kitsu.io/api/edge', | ||
@@ -36,2 +40,3 @@ timeout: options.timeout || 30000 | ||
this.remove = this.delete; | ||
this.interceptors = this.axios.interceptors; | ||
@@ -42,11 +47,13 @@ } | ||
let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
try { | ||
const headers = { ...this.headers, | ||
const headers = { | ||
...this.headers, | ||
...config.headers | ||
}; | ||
const params = { ...{}, | ||
const params = { | ||
...{}, | ||
...config.params | ||
}; | ||
const [res, id, relationship, subRelationship] = model.split('/'); | ||
let url = this.plural(this.resCase(res)); | ||
@@ -65,3 +72,4 @@ if (id) url += `/${this.resCase(id)}`; | ||
}); | ||
return responseHeaders ? { ...kitsuCore.deserialise(data), | ||
return responseHeaders ? { | ||
...kitsuCore.deserialise(data), | ||
...{ | ||
@@ -78,8 +86,9 @@ headers: responseHeaders | ||
let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
try { | ||
const headers = { ...this.headers, | ||
const headers = { | ||
...this.headers, | ||
...config.headers | ||
}; | ||
const params = { ...{}, | ||
const params = { | ||
...{}, | ||
...config.params | ||
@@ -105,3 +114,4 @@ }; | ||
}); | ||
return responseHeaders ? { ...kitsuCore.deserialise(data), | ||
return responseHeaders ? { | ||
...kitsuCore.deserialise(data), | ||
...{ | ||
@@ -118,8 +128,9 @@ headers: responseHeaders | ||
let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
try { | ||
const headers = { ...this.headers, | ||
const headers = { | ||
...this.headers, | ||
...config.headers | ||
}; | ||
const params = { ...{}, | ||
const params = { | ||
...{}, | ||
...config.params | ||
@@ -143,3 +154,4 @@ }; | ||
}); | ||
return responseHeaders ? { ...kitsuCore.deserialise(data), | ||
return responseHeaders ? { | ||
...kitsuCore.deserialise(data), | ||
...{ | ||
@@ -156,8 +168,9 @@ headers: responseHeaders | ||
let config = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
try { | ||
const headers = { ...this.headers, | ||
const headers = { | ||
...this.headers, | ||
...config.headers | ||
}; | ||
const params = { ...{}, | ||
const params = { | ||
...{}, | ||
...config.params | ||
@@ -171,3 +184,2 @@ }; | ||
let path, payload; | ||
if (isBulk) { | ||
@@ -184,3 +196,2 @@ path = url; | ||
} | ||
const { | ||
@@ -199,3 +210,4 @@ data, | ||
}); | ||
return responseHeaders ? { ...kitsuCore.deserialise(data), | ||
return responseHeaders ? { | ||
...kitsuCore.deserialise(data), | ||
...{ | ||
@@ -212,8 +224,9 @@ headers: responseHeaders | ||
let config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; | ||
try { | ||
const headers = { ...this.headers, | ||
const headers = { | ||
...this.headers, | ||
...config.headers | ||
}; | ||
const params = { ...config.params, | ||
const params = { | ||
...config.params, | ||
...{ | ||
@@ -225,3 +238,4 @@ filter: { | ||
}; | ||
const res = await this.get('users', { ...{ | ||
const res = await this.get('users', { | ||
...{ | ||
headers | ||
@@ -234,3 +248,4 @@ }, | ||
}); | ||
return res.headers ? { ...{ | ||
return res.headers ? { | ||
...{ | ||
data: res.data[0] | ||
@@ -259,6 +274,4 @@ }, | ||
} = _ref; | ||
try { | ||
var _method; | ||
method = ((_method = method) === null || _method === void 0 ? void 0 : _method.toUpperCase()) || 'GET'; | ||
@@ -275,3 +288,4 @@ const { | ||
}), | ||
headers: { ...this.headers, | ||
headers: { | ||
...this.headers, | ||
...headers | ||
@@ -283,3 +297,4 @@ }, | ||
}); | ||
return responseHeaders ? { ...kitsuCore.deserialise(data), | ||
return responseHeaders ? { | ||
...kitsuCore.deserialise(data), | ||
...{ | ||
@@ -293,5 +308,4 @@ headers: responseHeaders | ||
} | ||
} | ||
module.exports = Kitsu; |
{ | ||
"version": "10.0.2", | ||
"version": "10.0.3", | ||
"name": "kitsu", | ||
@@ -53,3 +53,3 @@ "description": "A simple, lightweight & framework agnostic JSON:API client using Axios", | ||
"axios": "^0.27.0", | ||
"kitsu-core": "^10.0.2", | ||
"kitsu-core": "^10.0.3", | ||
"pluralize": "^8.0.0" | ||
@@ -71,3 +71,3 @@ }, | ||
"devDependencies": { | ||
"@size-limit/preset-small-lib": "~8.0.0" | ||
"@size-limit/preset-small-lib": "~8.1.0" | ||
}, | ||
@@ -74,0 +74,0 @@ "exports": { |
@@ -244,3 +244,3 @@ <h1 align=center>Kitsu</h1> | ||
[packages/kitsu/src/index.js:30-523](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/packages/kitsu/src/index.js#L30-L523 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:30-529](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu/src/index.js#L30-L529 "Source code on GitHub") | ||
@@ -255,4 +255,4 @@ Creates a new `kitsu` instance | ||
* `options.headers` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional headers to send with the requests | ||
* `options.camelCaseTypes` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If enabled, `type` will be converted to camelCase from kebab-casae or snake_case (optional, default `true`) | ||
* `options.resourceCase` **(`"kebab"` | `"snake"` | `"none"`)** Case to convert camelCase to. `kebab` - `/library-entries`; `snake` - /library_entries` ; `none`-`/libraryEntries\` (optional, default `kebab`) | ||
* `options.camelCaseTypes` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If enabled, `type` will be converted to camelCase from kebab-casae or snake\_case (optional, default `true`) | ||
* `options.resourceCase` **(`"kebab"` | `"snake"` | `"none"`)** Case to convert camelCase to. `kebab` - `/library-entries`; `snake` - /library\_entries`; `none`-`/libraryEntries\` (optional, default `kebab`) | ||
* `options.pluralize` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** If enabled, `/user` will become `/users` in the URL request and `type` will be pluralized in POST, PATCH and DELETE requests (optional, default `true`) | ||
@@ -291,3 +291,3 @@ * `options.timeout` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Set the request timeout in milliseconds (optional, default `30000`) | ||
[packages/kitsu/src/index.js:52-53](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/packages/kitsu/src/index.js#L52-L53 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:52-53](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu/src/index.js#L52-L53 "Source code on GitHub") | ||
@@ -311,3 +311,3 @@ * **See**: <https://www.npmjs.com/package/pluralize> for documentation | ||
[packages/kitsu/src/index.js:67-67](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/packages/kitsu/src/index.js#L67-L67 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:67-67](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu/src/index.js#L67-L67 "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/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/packages/kitsu/src/index.js#L113-L113 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:113-113](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/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:211-240](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/packages/kitsu/src/index.js#L211-L240 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:211-240](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu/src/index.js#L211-L240 "Source code on GitHub") | ||
@@ -526,3 +526,3 @@ Fetch resources (alias `fetch`) | ||
[packages/kitsu/src/index.js:276-304](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/packages/kitsu/src/index.js#L276-L304 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:276-304](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu/src/index.js#L276-L304 "Source code on GitHub") | ||
@@ -589,3 +589,3 @@ Update a resource (alias `update`) | ||
[packages/kitsu/src/index.js:334-360](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/packages/kitsu/src/index.js#L334-L360 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:338-364](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu/src/index.js#L338-L364 "Source code on GitHub") | ||
@@ -611,8 +611,12 @@ Create a new resource (alias `create`) | ||
targetUser: { | ||
id: '42603', | ||
type: 'users' | ||
data: { | ||
id: '42603', | ||
type: 'users' | ||
} | ||
}, | ||
user: { | ||
id: '42603', | ||
type: 'users' | ||
data: { | ||
id: '42603', | ||
type: 'users' | ||
} | ||
} | ||
@@ -635,3 +639,3 @@ }) | ||
[packages/kitsu/src/index.js:378-412](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/packages/kitsu/src/index.js#L378-L412 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:384-418](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu/src/index.js#L384-L418 "Source code on GitHub") | ||
@@ -652,2 +656,8 @@ Remove a resource (alias `remove`) | ||
Remove one or more relationships from a resource | ||
```javascript | ||
api.delete('posts/1/relationships/uploads', [456, 789]) | ||
``` | ||
Remove a single resource | ||
@@ -669,3 +679,3 @@ | ||
[packages/kitsu/src/index.js:436-445](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/packages/kitsu/src/index.js#L436-L445 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:442-451](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu/src/index.js#L442-L451 "Source code on GitHub") | ||
@@ -708,3 +718,3 @@ Get the authenticated user's data | ||
[packages/kitsu/src/index.js:500-522](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/packages/kitsu/src/index.js#L500-L522 "Source code on GitHub") | ||
[packages/kitsu/src/index.js:506-528](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu/src/index.js#L506-L528 "Source code on GitHub") | ||
@@ -711,0 +721,0 @@ Send arbitrary requests |
@@ -278,8 +278,12 @@ /** | ||
* targetUser: { | ||
* id: '42603', | ||
* type: 'users' | ||
* data: { | ||
* id: '42603', | ||
* type: 'users' | ||
* } | ||
* }, | ||
* user: { | ||
* id: '42603', | ||
* type: 'users' | ||
* data: { | ||
* id: '42603', | ||
* type: 'users' | ||
* } | ||
* } | ||
@@ -308,2 +312,4 @@ * }) | ||
* @returns {Object|Object[]} JSON-parsed response | ||
* @example <caption>Remove one or more relationships from a resource</caption> | ||
* api.delete('posts/1/relationships/uploads', [456, 789]) | ||
* @example <caption>Remove a single resource</caption> | ||
@@ -310,0 +316,0 @@ * api.delete('posts', 123) |
Sorry, the diff of this file is not supported yet
87253
964
784
Updatedkitsu-core@^10.0.3