@khanacademy/wonder-blocks-data 3.1.2 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/dist/es/index.js +408 -349
  3. package/dist/index.js +568 -467
  4. package/docs.md +17 -35
  5. package/package.json +1 -1
  6. package/src/__tests__/__snapshots__/generated-snapshot.test.js.snap +7 -46
  7. package/src/__tests__/generated-snapshot.test.js +60 -126
  8. package/src/components/__tests__/data.test.js +373 -313
  9. package/src/components/__tests__/intercept-requests.test.js +58 -0
  10. package/src/components/data.js +139 -21
  11. package/src/components/data.md +38 -69
  12. package/src/components/gql-router.js +1 -1
  13. package/src/components/intercept-context.js +6 -3
  14. package/src/components/intercept-requests.js +69 -0
  15. package/src/components/intercept-requests.md +54 -0
  16. package/src/components/track-data.md +9 -23
  17. package/src/hooks/__tests__/__snapshots__/use-shared-cache.test.js.snap +17 -0
  18. package/src/hooks/__tests__/use-gql.test.js +1 -0
  19. package/src/hooks/__tests__/use-request-interception.test.js +255 -0
  20. package/src/hooks/__tests__/use-server-effect.test.js +217 -0
  21. package/src/hooks/__tests__/use-shared-cache.test.js +307 -0
  22. package/src/hooks/use-gql.js +39 -31
  23. package/src/hooks/use-request-interception.js +54 -0
  24. package/src/hooks/use-server-effect.js +45 -0
  25. package/src/hooks/use-shared-cache.js +106 -0
  26. package/src/index.js +17 -20
  27. package/src/util/__tests__/__snapshots__/scoped-in-memory-cache.test.js.snap +19 -0
  28. package/src/util/__tests__/request-fulfillment.test.js +42 -85
  29. package/src/util/__tests__/request-tracking.test.js +72 -191
  30. package/src/util/__tests__/{result-from-cache-entry.test.js → result-from-cache-response.test.js} +9 -10
  31. package/src/util/__tests__/scoped-in-memory-cache.test.js +396 -0
  32. package/src/util/__tests__/ssr-cache.test.js +639 -0
  33. package/src/util/gql-types.js +5 -10
  34. package/src/util/request-fulfillment.js +36 -44
  35. package/src/util/request-tracking.js +62 -75
  36. package/src/util/{result-from-cache-entry.js → result-from-cache-response.js} +10 -13
  37. package/src/util/scoped-in-memory-cache.js +149 -0
  38. package/src/util/ssr-cache.js +206 -0
  39. package/src/util/types.js +43 -108
  40. package/src/components/__tests__/intercept-data.test.js +0 -87
  41. package/src/components/intercept-data.js +0 -77
  42. package/src/components/intercept-data.md +0 -65
  43. package/src/hooks/__tests__/use-data.test.js +0 -826
  44. package/src/hooks/use-data.js +0 -143
  45. package/src/util/__tests__/memory-cache.test.js +0 -446
  46. package/src/util/__tests__/request-handler.test.js +0 -121
  47. package/src/util/__tests__/response-cache.test.js +0 -879
  48. package/src/util/memory-cache.js +0 -187
  49. package/src/util/request-handler.js +0 -42
  50. package/src/util/request-handler.md +0 -51
  51. package/src/util/response-cache.js +0 -213
package/CHANGELOG.md CHANGED
@@ -1,5 +1,46 @@
1
1
  # @khanacademy/wonder-blocks-data
2
2
 
3
+ ## 5.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 5b5f85ac: Replace `InterceptData` with `InterceptRequests` and introduce new `useRequestInterception` hook
8
+
9
+ ## 4.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - febc7309: Rename types and update signatures
14
+ - `ValidData` is now `ValidCacheData`
15
+ - `Cache` type is now `ResponseCache` (old `ResponseCache` can be created with `$ReadOnly<ResponseCache>`)
16
+ - `CacheEntry` type is now `CachedResponse`
17
+ - Signatures that were typed as `$ReadOnly<Cache>` previously are now typed as `ResponseCache` which is more appropriate to how they work
18
+ - bffc345e: Simplified, more versatile API
19
+
20
+ - NEW: `useServerEffect` hook - a way to perform asynchronous tasks on the server and have the value available for hydration
21
+ - UPDATED: `Data` component - New API that does away with the `IRequestHandler` interface. Includes new props to control behavior on hydration and when new requests occur.
22
+ - UPDATED: `InterceptData` component - New API to reflect changes in `Data` component.
23
+
24
+ - REMOVED: `IRequestHandler` API. All associated call signatures have been updated to reflect this.
25
+ - REMOVED: `useData` hook - The `Data` component should be used
26
+
27
+ ### Minor Changes
28
+
29
+ - 7c9dd09b: - New `useSharedData` hook
30
+ - New `ScopedInMemoryCache` export
31
+
32
+ ## 3.2.0
33
+
34
+ ### Minor Changes
35
+
36
+ - 6973afa2: useGql method now merges defaultContext and partial context by ignoring values explicitly set to undefined in the partial context. This ensures that that existing default context values are not overridden unless explicitly given a value other than undefined.
37
+
38
+ ## 3.1.3
39
+
40
+ ### Patch Changes
41
+
42
+ - 9931ae6b: Simplify GQL types
43
+
3
44
  ## 3.1.2
4
45
 
5
46
  ### Patch Changes