Skip to content

rest-hooks@5.0.0

Compare
Choose a tag to compare
@ntucker ntucker released this 19 Jan 17:29
· 2922 commits to master since this release
rest-hooks@5.0.0
987d81d

5.0.0 (2021-01-19)

Upgrade Guide

⚠ 💥 BREAKING CHANGES

Network Definitions (Resource/FetchShape, etc)

  • Resource
    • getFetchOptions() deprecated in favor of Resource.getFetchInit()
    • Resource getKey() deleted. Use get key() [previously deprecated]
    • Resource.getEntitySchema() removed, use Resource directly [previously deprecated]
    • Resource.asSchema() deprecated, use Resource directly
    • During development schema will be validated for expected values. This might throw new errors.
  • FetchShape
    • schema of delete shape should be the new schemas.Delete()
    • type is now just 'read' | 'mutate'. No more 'delete'. (use schema.Delete())

Managers

  • Action creator arguments changed
    • Mutates produce the same action type as 'read's
  • Mutation fetches now result in:
    • meta entries
    • results entries
  • url -> key on all action.meta
  • Added promise to FetchAction['meta']

Cache Lifetime Policy

  • deletes no long remove entities, but replace them with DELETE symbol (exported from normalizr)
  • useInvalidator()'s function calls will always suspend - even without invalidIfStale
  • deleted entities that are required by a useResource() will now cause it to suspend rather than throwing 404
  • required entities missing from network response will now throw error in useResource() just like other unexpected deserializations
  • When invalidIfStale is true, useCache() and useStatefulResource() will no longer return entities, even if they are in the cache

Tooling Requirements:

  • Node engine requirement of >=0.12

🚀 Features

  • Add ConnectionListener and a default browser implementation (#305) (f63f66c)
  • Add createFetch() action creator (#320) (392ea15)
  • Add DevToolsManager to integrate with redux-devtools (#371) (aa171bc)
  • Deletes and invalidates trigger suspense always (#360) (96175ba)
  • Entity fully denormalizes & Entity -> FlatEntity for non-nested (#328) (dd5e513)
  • Export EntitySchema and EntityInstance types (edef484)
  • Export ParamsFromShape type (df12329)
  • Resource.fetch() arguments reflect browser fetch() (#362) (1d19421)
  • Simplified Entity class (#315) (0e6bfcb)

💅 Enhancement

  • Add back remaining normalizr exports to rest-hooks (b6878ee)
  • Add buildInferredResults and isEntity to INTERNAL (f88717b)
  • Add default serializer to useSelectionUnstable (f2d6d14)
  • Add optional generic for fetch return value in shape types (#311) (280fa3d)
  • Commonjs bundle uses native-compatible code (#263) (5da9047)
  • console instead of throw when missing frequency (8708b1f)
  • Detect more cases of network mismatching schema (#331) (2af464f)
  • Devmode: Throw error if delete shape fetched with wrong schema (#240) (130e070)
  • Don't export action types (#239) (41fedfe)
  • Don't rollup normalizr and use-enhanced-reducer into rest-hooks (c6f1e12)
  • Easier to handle http fetch headers in response (#208) (86074a6)
  • Export DevToolsManager from rest-hooks (b8082ca)
  • Immediately fetch polling subscriptions (#228) (ae02bff)
  • Include context in error message when failing to build PK (b754a64)
  • Infer returntype of useFetcher()'s functions (#310) (bb75c15)
  • Keep legacy Resource (#376) (fdd1f7c)
  • Keep referential equality in list views (#251) (caf2bf7)
  • Maintain referential equality globally (#403) (e1e353d)
  • Make SimpleRecord's unique identifier keyed by symbol (6f0781b)
  • Make useResource() param type errors more readable (2de35ce)
  • Move testing modules to own package (#182) (174461a)
  • New package @rest-hooks/core (#336) (bf490c0)
  • NM only marks fetch processing in dev mode (3bfec50)
  • No longer require 'asSchema()' (#335) (a29c41b)
  • Non-ES bundlers will use IE11 compatible build (29eaefc)
  • Only include DevToolsManager in dev mode (#382) (5dbfbeb)
  • Polling subscriptions handle offline/online (#227) (38c9bc6)
  • Refine action creator interface (#327) (8cdc119)
  • Remove extraneous generics on Resource statics (3be6a6a)
  • Remove getEntitySchema() (a90cfd5)
  • Remove getKey() from Resource (3eafa5b)
  • Remove lodash dependency, reducing total bundle size (#250) (1e2bff1)
  • Rename action.meta.url to 'key' (#325) (5a06fe4)
  • Resource uses endpoint (#365) (4472106)
  • Resource.fetch uses fetch instead of superagent (#199) (5c740ec)
  • rest-hooks package should only import from core (f7c7134)
  • Schemas with no entities should not infer (#323) (79f048d)
  • Simplify NM existance check in dev mode (47afd8d)
  • Simplify online/offline polling logic (#308) (3be8e9d)
  • State updates from mutate/read now the same (#326) (c789dfb)
  • Support React 17 (#397) (a833f07)
  • Use latest normalizr denormalize export (4a55ce1)
  • useCache() and useStatefulResource() respect invalidIfStale (#307) (58f2c40)
  • useResource array parameters as readonly (#319) (fb1b39f)

🐛 Bug Fix

  • 0 for expiryLength should not result in default (#296) (c75dca5)
  • Add generic useResource parallel overloads for up to 16 arguments (#281) (da1578e)
  • Add lodash types (#198) (0523401)
  • CacheProvider in rest-hooks no longer infinitely recurses (d2ded89)
  • Connection listener feature detection (5b360df)
  • DevToolsManager being removed in production making exports not work (024c27e)
  • DevToolsManager export in prod mode (7f419cb)
  • Do not run reducer on non-optimistic fetches (#302) (86cc80b)
  • Don't crash polling subscriptions on react native (f57cd41)
  • Don't throw when RN tries to poll (#291) (6a57af9)
  • Entity export (c4d3136)
  • Export * for types (3968d51)
  • Export correct CacheManager with PolingManager as default (a6a99a0)
  • Export Endpoint through core (8b60dea)
  • Fix schema.Delete import (6106447)
  • Infer useFetcher() has no body when not present in fetch (#385) (22dd399)
  • Inferred results are considered stale (fc4ee61)
  • Inferring with union types (5ab6159)
  • Make SubscriptionManager type compatible with redux-toolkit (#235) (9e04388)
  • NetworkError type export should not be exposed to js build (de9413c)
  • Optimistic updates now trigger for results with empty string (#248) (6ac25ac)
  • Poll fetches while testing should be wrapped in act (#268) (9c264bb)
  • Put DevToolsManager at front so it captures all actions (ec2169b)
  • Resource endpoint memoization (744431e)
  • Test coverage (c3d51e2)
  • Tests run in node 12 (#202) (58e55e0)
  • Type inferencing for hooks (1fa5f2c)
  • TypeScript 4 compatibility (#406) (5d82e24)
  • useCache() with indexes but no entities ever stored (#279) (67a1257)

📦 Package

📝 Documentation

  • Add link to debugging docs from readme (d75cbe8)
  • Fix Endpoint def in readme example (125ad57)
  • Fix svg links in README (7cad255)
  • Get rid of all references to asSchema() (#339) (01b878b)
  • Point to repository directory for npm (942a563)
  • Update readme examples (68c69ab)
  • Update readme tagline (fe39b16)
  • Use bundlephobia badge for lib size (eb76258)