Releases: thorgate/tg-resources
Version 3.0.2
Affected packages:
@thorgate/redux-saga-router
New:
- Add
isSagaResource
andisSagaResourceInitialized
typeguards - Add
resourceEffectFactory
to help with library building
Version 3.0.1
- Update
@thorgate/redux-saga-router
to have better support for testing
Packages affected:
tg-resources@3.0.1
@tg-resources/redux-saga-router@3.0.1
@tg-resources/fetch@3.0.1
@tg-resources/superagent@3.0.1
Version 3.0.0
This release converts the source to typescript and was brought to you by @metsavaht in #32. Awesome!
- ❗ Added new config option
boolean allowAttachments
which must be set to true to useattachments
field with post and friends (see #32) - ❗ Added
window.fetch
backend (see #32)- npm package is
@tg-resources/fetch
- npm package is
- ❗ Moved superagent backend to
@tg-resources/superagent
getError
now supports array based arguments (see #18 and #32)- Added
createRouter
helper (see usage and #32) - Experimental: Added
saga-router
for easier integration with redux-saga- see usage
- Source is typescript now (see #32)
- Split source to micropackages using lerna
- Internal:
Resource.buildThePath
has been renamed toResource.renderPath
- Added
Router.routeName
andResouce.routeName
which reflects bound name inRouter
Upgrading from 2.0.0
-
Router
is not a default export anymoreold:
import Router from 'tg-resources';
new:import { Router } from 'tg-resources';
-
Resource
must be imported from sub-package, for example:fetch:
import { FetchResource as Resource } from '@tg-resources/fetch';
superagent:import { SuperAgentResource as Resource } from '@tg-resources/superagent';
-
Use
allowAttachments
configuration option when usingattachments
argument with post & friends. -
Use
Resource.renderPath
instead ofResource.buildThePath
v3.0.0-alpha.1
- Update
@thorgate/redux-saga-router
to have better support for testing - Fix
@tg-resources/fetch-runtime
missing entry-point in package
Version 3.0.0-alpha.0
This release converts the source to typescript and was brought to you by @metsavaht in #32. Awesome!
- ❗ Added new config option
boolean allowAttachments
which must be set to true to useattachments
field with post and friends (see #32) - ❗ Added
window.fetch
backend (see #32)- npm package is
@tg-resources/fetch
- npm package is
- ❗ Moved superagent backend to
@tg-resources/superagent
getError
now supports array based arguments (see #18 and #32)- Added
createRouter
helper (see usage and #32) - Experimental: Added
saga-router
for easier integration with redux-saga- see usage
- Source is typescript now (see #32)
- Split source to micropackages using lerna
- Internal:
Resource.buildThePath
has been renamed toResource.renderPath
Upgrading from 2.0.0
-
Router
is not a default export anymoreold:
import Router from 'tg-resources';
new:import { Router } from 'tg-resources';
-
Resource
must be imported from sub-package, for example:fetch:
import { FetchResource as Resource } from '@tg-resources/fetch';
superagent:import { SuperAgentResource as Resource } from '@tg-resources/superagent';
-
Use
allowAttachments
configuration option when usingattachments
argument with post & friends. -
Use
Resource.renderPath
instead ofResource.buildThePath
Version 2.0.0
- ❗ Error handling reworked (see docs)
- ❗ Renamed
ValidationError
to 'RequestValidationError` (migration) - ❗ Removed deprecated
ValidationError.getFieldError
- ❗ Renamed internal
.options
(per resource/router) to.config
(see #10) - ❗
parseErrors
now gets parent config not parent instance as it's second argument - ❗
prepareErrors
now gets parent config not parent instance as it's second argument - ❗ Removed
defaultHeaders
- useheaders
ordefaultAcceptHeader
- ❗ Setting
Accept
header to undefined/null does not cause the response to be parsed
as text anymore. When migrating, just setAccept
totext/html
. - ❗
Resource.get
andResource.post
method
argument moved - Added built-in for
OPTIONS
request:Resource.options
(see #10) - Added new configuration parameter
mutateError
(see docs) - Added
defaultAcceptHeader
(see docs) - Added
mutateRawResponse
andwithCredentials
option (see #24) - Added support for attachments with multi-part requests
- Removed separate
tg-resources-react-native
package. Users of older
versions of it can safely update totg-resources@2.0.0
- Deterministic config merge (+ tests for it)
- Use
jsnext:main
andmodule
fields in package.json - Use
react-native
field in package.json - Update dev dependencies
- Docs: Document extra arguments of
mutateResponse
- Docs: Add call signatures for
parseErrors
- Docs: Add call signatures for
prepareError
- Docs: Added examples
Migrating to 2.0.0
-
Custom headers
old:
new Resource('/', { defaultHeaders: {'x-foo': 'bar' } })
new:new Resource('/', { headers: { 'x-foo': 'bar' })
see also
defaultAcceptHeader
-
Resource arguments changed
old:
resource.fetch(kwargs, query, method = 'get') resource.post(kwargs, data, query, method = 'post) ...
new:
resource.fetch(kwargs, query, requestConfig = null, method ='get) resource.post(kwargs, data, query, attachments, requestConfig = null, method = 'post') ...
-
Router resource name
config
is now reservedold:
new Router({ config: ... })
new:new Router({ anythingElse: ... })
(
options
is no longer reserved) -
Router/resource configuration
old:
router.options
new:router.config()
old:
resource.options
new:resource.config()
new:resource.config(resourceConfig)
Similarly resource methods now take an optional
resourceConfig
as the last argument.Can be updated with
router.setConfig
andresource.setConfig
Configuration for a router is applied downwards to all resources of it.
-
Errors
old:
new ValidationError(err, options, isPrepared)
new:new RequestValidationError(statusCode, responseText, config)
The error handling has been greatly improved to handle
nested errors, see docs and examples for details.RequestValidationError
contains the result of theparseErrors
config
in theerrors
attribute, the default implementation will return
something implementingValidationErrorInterface
.old:
error.firstError()
new:error.errors.firstError()
old:
error.getFieldError(fieldName)
new:error.errors.getError(fieldName, allowNonFields = false)
parseErrors and prepareError now get the parent configuration
instead of the parent as the second argument:old:
parseErrors(errorText, instance)
new:parseErrors(errorText, requestConfig)
old:
prepareErrors(error, instance)
new:prepareErrors(error, requestConfig)
Version 2.0.0-alpha.11
- Warning: Signature for
post/put/patch/del
has changed:method(kwargs, data, query, requestConfig = null)
->method(kwargs, data, query, attachments, requestConfig = null)
- Where attachments is:
Array<Attachment { field: string, file: Blob/File, name: string }>
- Add support for attachments to
post/put/patch/del
(see #25) - This also fixes a bug w/
fetch
introduced in2.0.0-alpha.10
Version 2.0.0-alpha.10
- Broken: Please use 2.0.0-alpha.11
Version 2.0.0-alpha.9
- Skip cleanup in travis (to ensure es/dist directories are pushed to npm).