-
The
makeResource
should now be used like this:class Pokemon extends makeResource<Pokemon>('api/pokemon')
Instead of the old way:
class Pokemon extends makeResource('api/pokemon')<Pokemon>
By putting the generic directly after
makeResource
TypeScript actually recognizes the return types correcty. Before callingPokemon.one
would give back aPromise<unknown>
instead ofPromise<Pokemon>
. This way we no longer need to tell TypeScript the type when using it:const pokemon: Pokemon = await Pokemon.one(1);
And we can instead we can simply do:
// The type of pokemon is now correctly inferred as Pokemon const pokemon = await Pokemon.one(1);
-
The
findOne
method now returns aPromise
ofT
orvoid
. This way TypeScript recognizes the return type better, it did not understandnull
correctly, and acted as if it was aT
. Now TypeScript will make you check if you actually have a type T or empty. This was actually a bug discovered by the better type inference. -
No longer exporting a
Resource
class definition. It got out of sync really easily with the actual return value, so it has been removed.
- The
one
method now accepts a string for the id as well.
-
The
post
,patch
andput
payload parameter can now be aFormData
. Useful for totally controlling thebody
for example when uploading. -
Updated to TypeScript
3.5.3
had to makeQueryParams
the correct type as needed byquery-string
'sstringify
method. -
Exposed
Method
,MiddlewareDetailInfo
,QueryParams
in the index.
- Renamed to @42.nl/spring-connect
- Upgraded
lodash.merge
to resolve vulnerability warnings.
- Added
findOne
method which allows the user to search for one entity.
- Migrated from flow to TypeScript.
- Breaking makeResource now returns a class you can dynamically extend.
- Exposed applyMiddleware, getFetch and buildUrl to allow more customised calls
- Now passing the URL and optionally the queryParams and payload as extra parameters for the middleware
- Fixed a bug which caused the
emptyPage
from the spring-models not to be recognized as being of type Page.emptyPage
is now a function this way flow recognizes that each timeemptyPage
is called it returns a new type of Page.
- Fixed a bug which caused the
emptyPage
from the spring-models not to be recognized as being of type Page. This caused flow errors when using theemptyPage
more than once in an application.
- The first version of this library.