kitsu-core
Advanced tools
Comparing version 9.0.3 to 9.0.4
@@ -6,2 +6,21 @@ # Change Log | ||
## [9.0.4](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/compare/v9.0.3...v9.0.4) (2020-05-07) | ||
### Chores | ||
* **release:** update documentation ([9561c63](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/9561c63)) | ||
### Documentation Changes | ||
* **kitsu-core:** add example for query ([63c15f4](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/63c15f4)) | ||
* **kitsu-core:** add examples for error ([cb40de1](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/cb40de1)) | ||
* **kitsu-core:** add examples for filterIncludes ([66b5a6f](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/66b5a6f)) | ||
* **kitsu-core:** add examples for linkRelationships ([ff05659](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/commit/ff05659)) | ||
## [9.0.3](https://github.com/wopian/kitsu/tree/master/packages/kitsu-core/compare/v9.0.2...v9.0.3) (2020-05-07) | ||
@@ -8,0 +27,0 @@ |
{ | ||
"version": "9.0.3", | ||
"version": "9.0.4", | ||
"name": "kitsu-core", | ||
@@ -55,3 +55,3 @@ "description": "Core serialisation and deserialsation functions for the kitsu JSON:API client", | ||
], | ||
"gitHead": "5a805eedbea41921e161a7111eda595900818d80", | ||
"gitHead": "50a5b262a247fff519db750a1309fa84f74e69a1", | ||
"devDependencies": { | ||
@@ -58,0 +58,0 @@ "@size-limit/preset-small-lib": "~4.5.0" |
134
README.md
@@ -93,27 +93,31 @@ <h1 align=center>Kitsu Core</h1> | ||
- [Parameters](#parameters-2) | ||
- [Examples](#examples-2) | ||
- [filterIncludes](#filterincludes) | ||
- [Parameters](#parameters-3) | ||
- [Examples](#examples-3) | ||
- [linkRelationships](#linkrelationships) | ||
- [Parameters](#parameters-4) | ||
- [Examples](#examples-4) | ||
- [query](#query) | ||
- [Parameters](#parameters-5) | ||
- [Examples](#examples-5) | ||
- [serialise](#serialise) | ||
- [Parameters](#parameters-6) | ||
- [Examples](#examples-2) | ||
- [Examples](#examples-6) | ||
- [splitModel](#splitmodel) | ||
- [Parameters](#parameters-7) | ||
- [Examples](#examples-3) | ||
- [Examples](#examples-7) | ||
- [camel](#camel) | ||
- [Parameters](#parameters-8) | ||
- [Examples](#examples-4) | ||
- [Examples](#examples-8) | ||
- [kebab](#kebab) | ||
- [Parameters](#parameters-9) | ||
- [Examples](#examples-5) | ||
- [Examples](#examples-9) | ||
- [snake](#snake) | ||
- [Parameters](#parameters-10) | ||
- [Examples](#examples-6) | ||
- [Examples](#examples-10) | ||
### deattribute | ||
[packages/kitsu-core/src/deattribute/index.js:29-51](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu-core/src/deattribute/index.js#L29-L51 "Source code on GitHub") | ||
[packages/kitsu-core/src/deattribute/index.js:29-51](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu-core/src/deattribute/index.js#L29-L51 "Source code on GitHub") | ||
@@ -162,3 +166,3 @@ Hoists attributes to be top-level | ||
[packages/kitsu-core/src/deserialise/index.js:57-74](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu-core/src/deserialise/index.js#L57-L74 "Source code on GitHub") | ||
[packages/kitsu-core/src/deserialise/index.js:57-74](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu-core/src/deserialise/index.js#L57-L74 "Source code on GitHub") | ||
@@ -215,3 +219,3 @@ Deserialises a JSON-API response | ||
[packages/kitsu-core/src/error/index.js:7-13](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu-core/src/error/index.js#L7-L13 "Source code on GitHub") | ||
[packages/kitsu-core/src/error/index.js:27-33](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu-core/src/error/index.js#L27-L33 "Source code on GitHub") | ||
@@ -224,3 +228,27 @@ Uniform error handling for Axios, JSON:API and internal package errors. Mutated Error object is rethrown to the caller. | ||
#### Examples | ||
```javascript | ||
error('Hello') | ||
``` | ||
```javascript | ||
error({errors: [ { code: 400 } ]}) | ||
``` | ||
```javascript | ||
error({ | ||
response: { | ||
data: { | ||
errors: [ { | ||
title: 'Filter is not allowed', | ||
detail: 'x is not allowed', | ||
code: '102', | ||
status: '400' | ||
} ] | ||
} | ||
} | ||
}) | ||
``` | ||
- Throws **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The mutated Error | ||
@@ -230,5 +258,5 @@ | ||
[packages/kitsu-core/src/filterIncludes/index.js:12-25](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu-core/src/filterIncludes/index.js#L12-L25 "Source code on GitHub") | ||
[packages/kitsu-core/src/filterIncludes/index.js:33-46](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu-core/src/filterIncludes/index.js#L33-L46 "Source code on GitHub") | ||
Filters includes for the specific relationship | ||
Filters includes for the specific relationship requested | ||
@@ -238,6 +266,30 @@ #### Parameters | ||
- `included` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The response included object | ||
- `opts` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** | ||
- `opts.id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The relationship ID | ||
- `opts.type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The relationship type | ||
- `relationship` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** | ||
- `relationship.id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The relationship ID | ||
- `relationship.type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The relationship type | ||
#### Examples | ||
```javascript | ||
const includes = [ | ||
{ | ||
id: '1', | ||
type: 'users', | ||
attributes: { name: 'Emma' } | ||
}, | ||
{ | ||
id: '2', | ||
type: 'users', | ||
attributes: { name: 'Josh' } | ||
} | ||
] | ||
const relationship = { id: '1', type: 'users' } | ||
const response = filterIncludes(includes, relationship) | ||
// { | ||
// id: '1', | ||
// type: 'users', | ||
// attributes: { name: 'Emma' } | ||
// } | ||
``` | ||
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** The matched includes | ||
@@ -247,3 +299,3 @@ | ||
[packages/kitsu-core/src/linkRelationships/index.js:75-96](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu-core/src/linkRelationships/index.js#L75-L96 "Source code on GitHub") | ||
[packages/kitsu-core/src/linkRelationships/index.js:98-119](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu-core/src/linkRelationships/index.js#L98-L119 "Source code on GitHub") | ||
@@ -257,5 +309,32 @@ Links relationships to included data | ||
#### Examples | ||
```javascript | ||
const data = { | ||
attributes: { author: 'Joe' }, | ||
relationships: { | ||
author: { | ||
data: { id: '1', type: 'people' } | ||
} | ||
} | ||
} | ||
const included = [ { | ||
id: '1', | ||
type: 'people', | ||
attributes: { name: 'Joe' } | ||
} ] | ||
const output = linkRelationships(data, included) | ||
// { | ||
// attributes: { author: 'Joe' }, | ||
// author: { | ||
// data: { id: '1', name: 'Joe', type: 'people' } | ||
// } | ||
// } | ||
``` | ||
Returns **any** Parsed data | ||
### query | ||
[packages/kitsu-core/src/query/index.js:21-32](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu-core/src/query/index.js#L21-L32 "Source code on GitHub") | ||
[packages/kitsu-core/src/query/index.js:33-44](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu-core/src/query/index.js#L33-L44 "Source code on GitHub") | ||
@@ -269,2 +348,17 @@ Constructs a URL query string for JSON:API parameters | ||
#### Examples | ||
```javascript | ||
query({ | ||
filter: { | ||
slug: 'cowboy-bebop', | ||
title: { | ||
value: 'foo' | ||
} | ||
} | ||
sort: '-id' | ||
}) | ||
// filter%5Bslug%5D=cowboy-bebop&filter%5Btitle%5D%5Bvalue%5D=foo&sort=-id | ||
``` | ||
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** URL query string | ||
@@ -274,3 +368,3 @@ | ||
[packages/kitsu-core/src/serialise/index.js:119-152](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu-core/src/serialise/index.js#L119-L152 "Source code on GitHub") | ||
[packages/kitsu-core/src/serialise/index.js:119-152](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu-core/src/serialise/index.js#L119-L152 "Source code on GitHub") | ||
@@ -321,3 +415,3 @@ Serialises an object into a JSON-API structure | ||
[packages/kitsu-core/src/splitModel/index.js:29-39](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu-core/src/splitModel/index.js#L29-L39 "Source code on GitHub") | ||
[packages/kitsu-core/src/splitModel/index.js:29-39](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu-core/src/splitModel/index.js#L29-L39 "Source code on GitHub") | ||
@@ -365,3 +459,3 @@ Split model name from the model's resource URL | ||
[packages/kitsu-core/src/camel/index.js:14-14](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu-core/src/camel/index.js#L14-L14 "Source code on GitHub") | ||
[packages/kitsu-core/src/camel/index.js:14-14](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu-core/src/camel/index.js#L14-L14 "Source code on GitHub") | ||
@@ -394,3 +488,3 @@ Converts kebab-case and snake_case into camelCase | ||
[packages/kitsu-core/src/kebab/index.js:11-11](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu-core/src/kebab/index.js#L11-L11 "Source code on GitHub") | ||
[packages/kitsu-core/src/kebab/index.js:11-11](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu-core/src/kebab/index.js#L11-L11 "Source code on GitHub") | ||
@@ -413,3 +507,3 @@ Converts camelCase into kebab-case | ||
[packages/kitsu-core/src/snake/index.js:11-11](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu-core/src/snake/index.js#L11-L11 "Source code on GitHub") | ||
[packages/kitsu-core/src/snake/index.js:11-11](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu-core/src/snake/index.js#L11-L11 "Source code on GitHub") | ||
@@ -416,0 +510,0 @@ Converts camelCase into snake_case |
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
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
79840
531