Skip to content

Commit 8576749

Browse files
committed
docs(kitsu-core): add 9.0.0 migration guide
1 parent 8f899c5 commit 8576749

3 files changed

Lines changed: 128 additions & 4 deletions

File tree

packages/kitsu-core/MIGRATING.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,131 @@
11
# Migration Guides
22

3+
## Migrating to `9.0.0`
4+
5+
### Deserialising
6+
7+
`deserialise` and `linkRelationships` have been refactored. They now preserve `link` objects from relationships and match the structure of the root `data` object/array.
8+
- Root `data` self links are avaiable as `data.links` or `data[].links`
9+
- Relationship objects are now `relationshipName.data.id` from `relationshipName.id`
10+
- Relationship arrays are now `relationshipName.data[].id` from `relationshipName[].id`
11+
- Relationship links are avaiable as `relationshipName.links`
12+
13+
For the full change in behaviour, see the legacy and new outputs below.
14+
15+
#### Legacy Behaviour
16+
17+
Input:
18+
19+
```js
20+
data: {
21+
id: '1',
22+
type: 'libraryEntries'
23+
links: {
24+
self: 'https://kitsu.io/api/edge/library-entries/1'
25+
},
26+
attributes: {
27+
ratingTwenty: 10
28+
},
29+
relationships: {
30+
user: {
31+
links: {
32+
self: 'https://kitsu.io/api/edge/library-entries/1/relationships/user',
33+
related: 'https://kitsu.io/api/edge/library-entries/1/user'
34+
},
35+
data: {
36+
id: '2',
37+
type: 'users'
38+
}
39+
}
40+
}
41+
},
42+
included: [
43+
{
44+
id: '2',
45+
type: 'users',
46+
links: {
47+
self: 'https://kitsu.io/api/edge/users/2'
48+
},
49+
attributes: {
50+
name: 'Example'
51+
}
52+
}
53+
```
54+
55+
Output:
56+
57+
```js
58+
data: {
59+
id: '1',
60+
type: 'libraryEntries',
61+
ratingTwenty: 10,
62+
user: {
63+
id: '2',
64+
type: 'users',
65+
name: 'Example'
66+
}
67+
}
68+
```
69+
70+
#### New Behaviour
71+
72+
73+
Output with same input data as legacy behaviour:
74+
75+
```js
76+
data: {
77+
id: '1',
78+
type: 'libraryEntries',
79+
links: {
80+
self: 'https://kitsu.io/api/edge/library-entries/1'
81+
},
82+
ratingTwenty: 10,
83+
user: {
84+
links: {
85+
self: 'https://kitsu.io/api/edge/library-entries/1/relationships/user',
86+
related: 'https://kitsu.io/api/edge/library-entries/1/user'
87+
}
88+
data: {
89+
id: '2',
90+
type: 'users',
91+
links: {
92+
self: 'https://kitsu.io/api/edge/users/2'
93+
},
94+
name: 'Example'
95+
}
96+
}
97+
}
98+
```
99+
100+
### Serialising
101+
102+
`serialise` has been refactored. It now passes camel case and pluralisation options as argument options. Options are 100% optional and will default to no conversion or pluralisation (e.g libraryEntry -> libraryEntry).
103+
104+
#### Legacy Syntax
105+
106+
```js
107+
import { serialise, camel, kebab } from 'kitsu-core'
108+
import plural from 'pluralize'
109+
110+
serialise.apply({ camel, resCase: kebab, plural }, [ model, obj, 'PATCH' ])
111+
```
112+
113+
#### New Syntax
114+
115+
```js
116+
import { serialise, camel } from 'kitsu-core'
117+
import plural from 'pluralize'
118+
119+
serialise(model, obj, 'PATCH', {
120+
camelCaseTypes: camel,
121+
pluralTypes: plural
122+
})
123+
```
124+
3125
## Migrating to `8.0.0`
4126

127+
Dropped Node 8 support. Lowest supported version is now Node 10.
128+
5129
`kitsu-core/node` has been removed as it is now identical to`kitsu-core`.
6130

7131
- Replace `kitsu-core/node` imports with `kitsu-core`

packages/kitsu-core/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
| Package | Package<br> Size\* | Node | Chrome | Firefox | Safari | Edge |
4040
| ------------: | :----------------: | :--: | :----: | :-----: | :----: | :--: |
41-
| `kitsu-core`| ≤ 1.3 kb | 10+ | 79+ | 68+ | 12.1+ | 18+ |
41+
| `kitsu-core`| ≤ 1.4 kb | 10+ | 79+ | 68+ | 12.1+ | 18+ |
4242

4343
\* Including all dependencies, minified & gzipped<br>
4444

packages/kitsu-core/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@
4141
"size-limit": [
4242
{
4343
"path": "./lib/index.js",
44-
"limit": "1.4 kb"
44+
"limit": "1.5 kb"
4545
},
4646
{
4747
"path": "./lib/index.mjs",
48-
"limit": "1.4 kb"
48+
"limit": "1.5 kb"
4949
},
5050
{
5151
"path": "./lib/index.browser.js",
52-
"limit": "1.4 kb"
52+
"limit": "1.5 kb"
5353
}
5454
],
5555
"gitHead": "5c9778d191d17d7c9790cfc6d0f4e983b4742a53",

0 commit comments

Comments
 (0)