Skip to content

Commit

Permalink
chore(release): update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
wopian committed Oct 30, 2022
1 parent f6e53cb commit 173266f
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 34 deletions.
76 changes: 54 additions & 22 deletions packages/kitsu-core/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,27 @@ All code released under [MIT]
* [linkRelationships](#linkrelationships)
* [Parameters](#parameters-6)
* [Examples](#examples-6)
* [query](#query)
* [isDeepEqual](#isdeepequal)
* [Parameters](#parameters-7)
* [Examples](#examples-7)
* [serialise](#serialise)
* [query](#query)
* [Parameters](#parameters-8)
* [Examples](#examples-8)
* [snake](#snake)
* [serialise](#serialise)
* [Parameters](#parameters-9)
* [Examples](#examples-9)
* [splitModel](#splitmodel)
* [snake](#snake)
* [Parameters](#parameters-10)
* [Examples](#examples-10)
* [splitModel](#splitmodel)
* [Parameters](#parameters-11)
* [Examples](#examples-11)

### camel

[packages/kitsu-core/src/camel/index.js:14-14](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/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/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu-core/src/camel/index.js#L14-L14 "Source code on GitHub")

Converts kebab-case and snake_case into camelCase
Converts kebab-case and snake\_case into camelCase

#### Parameters

Expand All @@ -150,7 +153,7 @@ Convert kebab-case
camel('hello-world') // 'helloWorld'
```

Convert snake_case
Convert snake\_case

```javascript
camel('hello_world') // 'helloWorld'
Expand All @@ -160,7 +163,7 @@ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G

### deattribute

[packages/kitsu-core/src/deattribute/index.js:29-51](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/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/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu-core/src/deattribute/index.js#L29-L51 "Source code on GitHub")

Hoists attributes to be top-level

Expand Down Expand Up @@ -202,7 +205,7 @@ Returns **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/

### deserialise

[packages/kitsu-core/src/deserialise/index.js:62-77](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/packages/kitsu-core/src/deserialise/index.js#L62-L77 "Source code on GitHub")
[packages/kitsu-core/src/deserialise/index.js:62-77](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu-core/src/deserialise/index.js#L62-L77 "Source code on GitHub")

Deserialises a JSON-API response

Expand Down Expand Up @@ -252,7 +255,7 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G

### error

[packages/kitsu-core/src/error/index.js:27-33](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/packages/kitsu-core/src/error/index.js#L27-L33 "Source code on GitHub")
[packages/kitsu-core/src/error/index.js:27-33](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu-core/src/error/index.js#L27-L33 "Source code on GitHub")

Uniform error handling for Axios, JSON:API and internal package errors. Mutated Error object is rethrown to the caller.

Expand Down Expand Up @@ -289,14 +292,14 @@ error({

### filterIncludes

[packages/kitsu-core/src/filterIncludes/index.js:33-46](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/packages/kitsu-core/src/filterIncludes/index.js#L33-L46 "Source code on GitHub")
[packages/kitsu-core/src/filterIncludes/index.js:33-46](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu-core/src/filterIncludes/index.js#L33-L46 "Source code on GitHub")

Filters includes for the specific relationship requested

#### Parameters

* `included` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)>** The response included object
* `relationship` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
* `relationship` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**&#x20;

* `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
Expand Down Expand Up @@ -329,7 +332,7 @@ Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Gl

### kebab

[packages/kitsu-core/src/kebab/index.js:11-11](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/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/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu-core/src/kebab/index.js#L11-L11 "Source code on GitHub")

Converts camelCase into kebab-case

Expand All @@ -347,7 +350,7 @@ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G

### linkRelationships

[packages/kitsu-core/src/linkRelationships/index.js:127-147](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/packages/kitsu-core/src/linkRelationships/index.js#L127-L147 "Source code on GitHub")
[packages/kitsu-core/src/linkRelationships/index.js:144-164](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu-core/src/linkRelationships/index.js#L144-L164 "Source code on GitHub")

Links relationships to included data

Expand Down Expand Up @@ -385,9 +388,38 @@ const output = linkRelationships(data, included)

Returns **any** Parsed data

### isDeepEqual

[packages/kitsu-core/src/deepEqual/index.js:18-42](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu-core/src/deepEqual/index.js#L18-L42 "Source code on GitHub")

Compare two objects equality

#### Parameters

* `left` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object to compare against the right object
* `right` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Object to compare against the left object

#### Examples

Deep equality check

```javascript
isDeepEqual({
firstName: 'John',
lastName: 'Doe',
age: 35
},{
firstName: 'John',
lastName: 'Doe',
age: 35
}) // true
```

Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** Whether the objects are equal

### query

[packages/kitsu-core/src/query/index.js:33-42](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/packages/kitsu-core/src/query/index.js#L33-L42 "Source code on GitHub")
[packages/kitsu-core/src/query/index.js:34-43](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu-core/src/query/index.js#L34-L43 "Source code on GitHub")

Constructs a URL query string for JSON:API parameters

Expand Down Expand Up @@ -415,7 +447,7 @@ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G

### serialise

[packages/kitsu-core/src/serialise/index.js:213-224](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/packages/kitsu-core/src/serialise/index.js#L213-L224 "Source code on GitHub")
[packages/kitsu-core/src/serialise/index.js:213-224](https://github.com/wopian/kitsu/blob/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu-core/src/serialise/index.js#L213-L224 "Source code on GitHub")

Serialises an object into a JSON-API structure

Expand All @@ -426,7 +458,7 @@ Serialises an object into a JSON-API structure
* `method` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** Request type (PATCH, POST, DELETE) (optional, default `'POST'`)
* `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Optional configuration for camelCase and pluralisation handling (optional, default `{}`)

* `options.camelCaseTypes` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Convert library-entries and library_entries to libraryEntries (default no conversion). To use parameter, import camel from kitsu-core (optional, default `s=>s`)
* `options.camelCaseTypes` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Convert library-entries and library\_entries to libraryEntries (default no conversion). To use parameter, import camel from kitsu-core (optional, default `s=>s`)
* `options.pluralTypes` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Pluralise types (default no pluralisation). To use parameter, import pluralize (or another pluralisation npm package) (optional, default `s=>s`)

#### Examples
Expand Down Expand Up @@ -460,9 +492,9 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G

### snake

[packages/kitsu-core/src/snake/index.js:11-11](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/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/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu-core/src/snake/index.js#L11-L11 "Source code on GitHub")

Converts camelCase into snake_case
Converts camelCase into snake\_case

#### Parameters

Expand All @@ -474,11 +506,11 @@ Converts camelCase into snake_case
snake('helloWorld') // 'hello_world'
```

Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** snake_case formatted string
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** snake\_case formatted string

### splitModel

[packages/kitsu-core/src/splitModel/index.js:29-39](https://github.com/wopian/kitsu/blob/5b2c64c688eac3427ad5b21bd00ab456c7998e0b/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/f6e53cb3d654f12335370fb083969b12ee59ff94/packages/kitsu-core/src/splitModel/index.js#L29-L39 "Source code on GitHub")

Split model name from the model's resource URL

Expand All @@ -487,7 +519,7 @@ Split model name from the model's resource URL
* `url` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** URL path for the model
* `options` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Optional configuration for camelCase and pluralisation handling

* `options.resourceCase` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Convert libraryEntries to library-entries or library_entries (default no conversion). To use parameter, import kebab or snake from kitsu-core (optional, default `s=>s`)
* `options.resourceCase` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Convert libraryEntries to library-entries or library\_entries (default no conversion). To use parameter, import kebab or snake from kitsu-core (optional, default `s=>s`)
* `options.pluralModel` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)** Pluralise models (default no pluralisation). To use parameter, import pluralize (or another pluralisation npm package) (optional, default `s=>s`)

#### Examples
Expand Down
30 changes: 18 additions & 12 deletions packages/kitsu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ All code released under [MIT]

### Kitsu

[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")

Creates a new `kitsu` instance

Expand All @@ -251,8 +251,8 @@ Creates a new `kitsu` instance

* `options.baseURL` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Set the API endpoint (optional, default `https://kitsu.io/api/edge`)
* `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`)
* `options.timeout` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** Set the request timeout in milliseconds (optional, default `30000`)
* `options.axiosOptions` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)?** Additional options for the axios instance (see [axios/axios#request-config](https://github.com/axios/axios#request-config) for details)
Expand Down Expand Up @@ -286,7 +286,7 @@ const api = new Kitsu({

#### plural

[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")

* **See**: <https://www.npmjs.com/package/pluralize> for documentation
* **See**: [Kitsu](#kitsu) constructor options for disabling pluralization
Expand All @@ -305,7 +305,7 @@ api.plural.plural('paper') //=> 'paper'

#### headers

[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")

Get the current headers or add additional headers

Expand Down Expand Up @@ -333,7 +333,7 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G

#### interceptors

[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")

* **See**: <https://github.com/axios/axios#interceptors> for documentation

Expand Down Expand Up @@ -380,7 +380,7 @@ api.interceptors.request.eject(myInterceptor)

#### get

[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")

Fetch resources (alias `fetch`)

Expand Down Expand Up @@ -517,7 +517,7 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
#### patch
[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")
Update a resource (alias `update`)
Expand Down Expand Up @@ -579,7 +579,7 @@ Returns **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/
#### post
[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")
Create a new resource (alias `create`)
Expand Down Expand Up @@ -627,7 +627,7 @@ Returns **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/
#### delete
[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")
Remove a resource (alias `remove`)
Expand All @@ -643,6 +643,12 @@ Remove a resource (alias `remove`)
##### Examples
Remove one or more relationships from a resource
```javascript
api.delete('posts/1/relationships/uploads', [456, 789])
```
Remove a single resource
```javascript
Expand All @@ -659,7 +665,7 @@ Returns **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/
#### self
[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")
Get the authenticated user's data
Expand Down Expand Up @@ -697,7 +703,7 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
#### request
[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")
Send arbitrary requests
Expand Down
2 changes: 2 additions & 0 deletions packages/kitsu/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ export default class Kitsu {
* @param {Object} [config.headers] Additional headers to send with the request
* @param {Object} [config.axiosOptions] Additional options for the axios instance (see [axios/axios#request-config](https://github.com/axios/axios#request-config) for details)
* @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>
* api.delete('posts', 123)
* @example <caption>Remove multiple resources (API must support the Bulk Extension)</caption>
Expand Down

0 comments on commit 173266f

Please sign in to comment.