Skip to content

Commit 9561c63

Browse files
committed
chore(release): update documentation
1 parent ff05659 commit 9561c63

2 files changed

Lines changed: 123 additions & 29 deletions

File tree

packages/kitsu-core/README.md

Lines changed: 114 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -90,31 +90,35 @@ kitsuCore.camel(...)
9090
- [Examples](#examples-1)
9191
- [error](#error)
9292
- [Parameters](#parameters-2)
93+
- [Examples](#examples-2)
9394
- [filterIncludes](#filterincludes)
9495
- [Parameters](#parameters-3)
96+
- [Examples](#examples-3)
9597
- [linkRelationships](#linkrelationships)
9698
- [Parameters](#parameters-4)
99+
- [Examples](#examples-4)
97100
- [query](#query)
98101
- [Parameters](#parameters-5)
102+
- [Examples](#examples-5)
99103
- [serialise](#serialise)
100104
- [Parameters](#parameters-6)
101-
- [Examples](#examples-2)
105+
- [Examples](#examples-6)
102106
- [splitModel](#splitmodel)
103107
- [Parameters](#parameters-7)
104-
- [Examples](#examples-3)
108+
- [Examples](#examples-7)
105109
- [camel](#camel)
106110
- [Parameters](#parameters-8)
107-
- [Examples](#examples-4)
111+
- [Examples](#examples-8)
108112
- [kebab](#kebab)
109113
- [Parameters](#parameters-9)
110-
- [Examples](#examples-5)
114+
- [Examples](#examples-9)
111115
- [snake](#snake)
112116
- [Parameters](#parameters-10)
113-
- [Examples](#examples-6)
117+
- [Examples](#examples-10)
114118

115119
### deattribute
116120

117-
[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")
121+
[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")
118122

119123
Hoists attributes to be top-level
120124

@@ -158,7 +162,7 @@ Returns **([Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/
158162

159163
### deserialise
160164

161-
[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")
165+
[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")
162166

163167
Deserialises a JSON-API response
164168

@@ -210,35 +214,83 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
210214

211215
### error
212216

213-
[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")
217+
[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")
214218

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

217221
#### Parameters
218222

219223
- `E` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The Error
220224

225+
#### Examples
226+
227+
```javascript
228+
error('Hello')
229+
```
230+
231+
```javascript
232+
error({errors: [ { code: 400 } ]})
233+
```
234+
235+
```javascript
236+
error({
237+
response: {
238+
data: {
239+
errors: [ {
240+
title: 'Filter is not allowed',
241+
detail: 'x is not allowed',
242+
code: '102',
243+
status: '400'
244+
} ]
245+
}
246+
}
247+
})
248+
```
221249

222250
- Throws **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The mutated Error
223251

224252
### filterIncludes
225253

226-
[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")
254+
[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")
227255

228-
Filters includes for the specific relationship
256+
Filters includes for the specific relationship requested
229257

230258
#### Parameters
231259

232260
- `included` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The response included object
233-
- `opts` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
234-
- `opts.id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The relationship ID
235-
- `opts.type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The relationship type
261+
- `relationship` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)**
262+
- `relationship.id` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The relationship ID
263+
- `relationship.type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** The relationship type
264+
265+
#### Examples
266+
267+
```javascript
268+
const includes = [
269+
{
270+
id: '1',
271+
type: 'users',
272+
attributes: { name: 'Emma' }
273+
},
274+
{
275+
id: '2',
276+
type: 'users',
277+
attributes: { name: 'Josh' }
278+
}
279+
]
280+
const relationship = { id: '1', type: 'users' }
281+
const response = filterIncludes(includes, relationship)
282+
// {
283+
// id: '1',
284+
// type: 'users',
285+
// attributes: { name: 'Emma' }
286+
// }
287+
```
236288

237289
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)** The matched includes
238290

239291
### linkRelationships
240292

241-
[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")
293+
[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")
242294

243295
Links relationships to included data
244296

@@ -247,9 +299,36 @@ Links relationships to included data
247299
- `data` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The response data object
248300
- `included` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** The response included object (optional, default `[]`)
249301

302+
#### Examples
303+
304+
```javascript
305+
const data = {
306+
attributes: { author: 'Joe' },
307+
relationships: {
308+
author: {
309+
data: { id: '1', type: 'people' }
310+
}
311+
}
312+
}
313+
const included = [ {
314+
id: '1',
315+
type: 'people',
316+
attributes: { name: 'Joe' }
317+
} ]
318+
const output = linkRelationships(data, included)
319+
// {
320+
// attributes: { author: 'Joe' },
321+
// author: {
322+
// data: { id: '1', name: 'Joe', type: 'people' }
323+
// }
324+
// }
325+
```
326+
327+
Returns **any** Parsed data
328+
250329
### query
251330

252-
[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")
331+
[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")
253332

254333
Constructs a URL query string for JSON:API parameters
255334

@@ -258,11 +337,26 @@ Constructs a URL query string for JSON:API parameters
258337
- `params` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** Parameters to parse
259338
- `prefix` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** Prefix for nested parameters - used internally (default `null`) (optional, default `null`)
260339

340+
#### Examples
341+
342+
```javascript
343+
query({
344+
filter: {
345+
slug: 'cowboy-bebop',
346+
title: {
347+
value: 'foo'
348+
}
349+
}
350+
sort: '-id'
351+
})
352+
// filter%5Bslug%5D=cowboy-bebop&filter%5Btitle%5D%5Bvalue%5D=foo&sort=-id
353+
```
354+
261355
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** URL query string
262356

263357
### serialise
264358

265-
[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")
359+
[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")
266360

267361
Serialises an object into a JSON-API structure
268362

@@ -308,7 +402,7 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
308402

309403
### splitModel
310404

311-
[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")
405+
[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")
312406

313407
Split model name from the model's resource URL
314408

@@ -351,7 +445,7 @@ Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Gl
351445

352446
### camel
353447

354-
[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")
448+
[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")
355449

356450
Converts kebab-case and snake_case into camelCase
357451

@@ -379,7 +473,7 @@ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
379473

380474
### kebab
381475

382-
[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")
476+
[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")
383477

384478
Converts camelCase into kebab-case
385479

@@ -397,7 +491,7 @@ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
397491

398492
### snake
399493

400-
[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")
494+
[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")
401495

402496
Converts camelCase into snake_case
403497

packages/kitsu/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ If you're working with [Kitsu.io]'s API, their [API docs][kitsu.io api docs] lis
210210

211211
### Kitsu
212212

213-
[packages/kitsu/src/index.js:30-342](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu/src/index.js#L30-L342 "Source code on GitHub")
213+
[packages/kitsu/src/index.js:30-342](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu/src/index.js#L30-L342 "Source code on GitHub")
214214

215215
Creates a new `kitsu` instance
216216

@@ -257,7 +257,7 @@ const api = new Kitsu({
257257

258258
#### plural
259259

260-
[packages/kitsu/src/index.js:52-53](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu/src/index.js#L52-L53 "Source code on GitHub")
260+
[packages/kitsu/src/index.js:52-53](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu/src/index.js#L52-L53 "Source code on GitHub")
261261

262262
- **See: <https://www.npmjs.com/package/pluralize> for documentation
263263
**
@@ -279,7 +279,7 @@ api.plural.plural('paper') //=> 'paper'
279279

280280
#### headers
281281

282-
[packages/kitsu/src/index.js:67-67](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu/src/index.js#L67-L67 "Source code on GitHub")
282+
[packages/kitsu/src/index.js:67-67](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu/src/index.js#L67-L67 "Source code on GitHub")
283283

284284
Get the current headers or add additional headers
285285

@@ -310,7 +310,7 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
310310

311311
#### interceptors
312312

313-
[packages/kitsu/src/index.js:111-111](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu/src/index.js#L111-L111 "Source code on GitHub")
313+
[packages/kitsu/src/index.js:111-111](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu/src/index.js#L111-L111 "Source code on GitHub")
314314

315315
Axios Interceptors (alias of `axios.interceptors`)
316316

@@ -358,7 +358,7 @@ api.interceptors.request.eject(myInterceptor)
358358

359359
#### get
360360

361-
[packages/kitsu/src/index.js:184-203](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu/src/index.js#L184-L203 "Source code on GitHub")
361+
[packages/kitsu/src/index.js:184-203](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu/src/index.js#L184-L203 "Source code on GitHub")
362362

363363
Fetch resources (alias `fetch`)
364364

@@ -470,7 +470,7 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
470470

471471
#### patch
472472

473-
[packages/kitsu/src/index.js:219-239](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu/src/index.js#L219-L239 "Source code on GitHub")
473+
[packages/kitsu/src/index.js:219-239](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu/src/index.js#L219-L239 "Source code on GitHub")
474474

475475
Update a resource (alias `update`)
476476

@@ -496,7 +496,7 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
496496

497497
#### post
498498

499-
[packages/kitsu/src/index.js:262-281](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu/src/index.js#L262-L281 "Source code on GitHub")
499+
[packages/kitsu/src/index.js:262-281](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu/src/index.js#L262-L281 "Source code on GitHub")
500500

501501
Create a new resource (alias `create`)
502502

@@ -529,7 +529,7 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
529529

530530
#### delete
531531

532-
[packages/kitsu/src/index.js:294-312](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu/src/index.js#L294-L312 "Source code on GitHub")
532+
[packages/kitsu/src/index.js:294-312](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu/src/index.js#L294-L312 "Source code on GitHub")
533533

534534
Remove a resource (alias `remove`)
535535

@@ -552,7 +552,7 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
552552

553553
#### self
554554

555-
[packages/kitsu/src/index.js:334-341](https://github.com/wopian/kitsu/blob/a5c501adbeffe96ad8ea7596a9a9e5511cebca72/packages/kitsu/src/index.js#L334-L341 "Source code on GitHub")
555+
[packages/kitsu/src/index.js:334-341](https://github.com/wopian/kitsu/blob/ff05659243c024afe9a4537a480fd59a26b9ba3d/packages/kitsu/src/index.js#L334-L341 "Source code on GitHub")
556556

557557
Get the authenticated user's data
558558

0 commit comments

Comments
 (0)