Skip to content

Releases: thorgate/tg-resources

Version 3.0.2

03 Dec 17:50
Compare
Choose a tag to compare

Affected packages:

  • @thorgate/redux-saga-router

New:

  • Add isSagaResource and isSagaResourceInitialized typeguards
  • Add resourceEffectFactory to help with library building

Version 3.0.1

30 Nov 14:44
Compare
Choose a tag to compare
  • 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

30 Nov 12:56
Compare
Choose a tag to compare

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 use attachments field with post and friends (see #32)
  • ❗ Added window.fetch backend (see #32)
    • npm package is @tg-resources/fetch
  • ❗ 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
  • Source is typescript now (see #32)
    • Split source to micropackages using lerna
  • Internal: Resource.buildThePath has been renamed to Resource.renderPath
  • Added Router.routeName and Resouce.routeName which reflects bound name in Router

Upgrading from 2.0.0

  1. Router is not a default export anymore

    old: import Router from 'tg-resources';
    new: import { Router } from 'tg-resources';

  2. 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';

  3. Use allowAttachments configuration option when using attachments argument with post & friends.

  4. Use Resource.renderPath instead of Resource.buildThePath

v3.0.0-alpha.1

26 Nov 13:44
Compare
Choose a tag to compare
v3.0.0-alpha.1 Pre-release
Pre-release
  • 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

13 Nov 13:54
Compare
Choose a tag to compare
Version 3.0.0-alpha.0 Pre-release
Pre-release

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 use attachments field with post and friends (see #32)
  • ❗ Added window.fetch backend (see #32)
    • npm package is @tg-resources/fetch
  • ❗ 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
  • Source is typescript now (see #32)
    • Split source to micropackages using lerna
  • Internal: Resource.buildThePath has been renamed to Resource.renderPath

Upgrading from 2.0.0

  1. Router is not a default export anymore

    old: import Router from 'tg-resources';
    new: import { Router } from 'tg-resources';

  2. 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';

  3. Use allowAttachments configuration option when using attachments argument with post & friends.

  4. Use Resource.renderPath instead of Resource.buildThePath

Version 2.0.0

20 Jun 16:08
8630925
Compare
Choose a tag to compare
  • ❗ 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 - use headers or defaultAcceptHeader
  • ❗ Setting Accept header to undefined/null does not cause the response to be parsed
    as text anymore. When migrating, just set Accept to text/html.
  • Resource.get and Resource.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 and withCredentials 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 to tg-resources@2.0.0
  • Deterministic config merge (+ tests for it)
  • Use jsnext:main and module 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

  1. Custom headers

    old: new Resource('/', { defaultHeaders: {'x-foo': 'bar' } })
    new: new Resource('/', { headers: { 'x-foo': 'bar' })

    see also defaultAcceptHeader

  2. 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')
    ...
    
  3. Router resource name config is now reserved

    old: new Router({ config: ... })
    new: new Router({ anythingElse: ... })

    ( options is no longer reserved)

  4. 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 and resource.setConfig

    Configuration for a router is applied downwards to all resources of it.

  5. 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 the parseErrors config
    in the errors attribute, the default implementation will return
    something implementing ValidationErrorInterface.

    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

06 Jun 10:39
3840116
Compare
Choose a tag to compare
Pre-release
  • 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 in 2.0.0-alpha.10

Version 2.0.0-alpha.10

05 Jun 13:18
9f63586
Compare
Choose a tag to compare
Pre-release
  • Broken: Please use 2.0.0-alpha.11

Version 2.0.0-alpha.9

16 May 14:31
47bf914
Compare
Choose a tag to compare
Version 2.0.0-alpha.9 Pre-release
Pre-release
  • Skip cleanup in travis (to ensure es/dist directories are pushed to npm).

Version 2.0.0-alpha.8

16 May 14:12
31207ee
Compare
Choose a tag to compare
Version 2.0.0-alpha.8 Pre-release
Pre-release
  • Add setConfig(config) to Router/Resource which can be used to overwrite router/resource config at runtime (see #25)
  • Add clearConfigCache() which can be used to clear internal configuration cache of routers/resources (see #25)