Skip to content

Commit

Permalink
3.0.0
Browse files Browse the repository at this point in the history
3.0.0
  • Loading branch information
lakardion authored Apr 28, 2024
2 parents e611a27 + d9c2e6b commit a9a123d
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 68 deletions.
67 changes: 0 additions & 67 deletions .changeset/tasty-wombats-pretend.md

This file was deleted.

78 changes: 78 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,83 @@
# @thinknimble/tn-models-fp

## 3.0.0

### Major Changes

- 2f61919: ## Migration Guide v2 - v3

### What's new?

- Now all functions accept a single object as parameter. No more secondary parameters.
- Improvements on the type layer ( non perceptible from user perspective). Removed all overloads for functions which were a pain to maintain. Now a single function definition makes the inference for all possibilities.

### How to migrate from v2

For a full fledged example on how to migrate you can check the test file changes on the [v3 PR](https://github.com/thinknimble/tn-models-fp/pull/186).

The summary is as follows:

#### `createCustomServiceCall`

- The callback no longer is in the second parameter. Instead we provide it in the first parameter as a `cb` field

```diff
const testPost = createCustomServiceCall(
{
inputShape,
outputShape,
+ cb: async ({ client, input, utils, slashEndingBaseUri }) => {
+ const toApiInput = utils.toApi(input)
+ const res = await client.post(slashEndingBaseUri, toApiInput)
+ const parsed = utils.fromApi(res.data)
+ return parsed
+ },
-async ({ client, input, utils, slashEndingBaseUri }) => {
- const toApiInput = utils.toApi(input)
- const res = await client.post(slashEndingBaseUri, toApiInput)
- const parsed = utils.fromApi(res.data)
- return parsed
-}
})
```

#### createPaginatedServiceCall

- options (`uri` and `httpMethod`) are no longer in the second parameter. Instead we pass them in an `opts` field in the first parameter.

```diff
const paginatedServiceCall = createPaginatedServiceCall(
{
outputShape,
inputShape,
+ opts: {
+ httpMethod: "post"
+ }
},
- { httpMethod: "post" }
)
```

#### `createApi`

- If you don't have any custom calls in the `createApi` call then you should be good ✅
- If you do have custom calls, move the second parameter into a `customCalls` field in the first parameter.

```diff
const testApi = createApi(
{
baseUri,
client: mockedAxios,
+ customCalls: {
+ testPost
+ }
},
- {
- testPost,
- }
)
```

## 2.5.0

### Minor Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@thinknimble/tn-models",
"version": "2.5.0",
"version": "3.0.0",
"description": "Utilities for building front-end models when using snake-cased backends.",
"author": "Thinknimble",
"license": "MIT",
Expand Down

0 comments on commit a9a123d

Please sign in to comment.