@khanacademy/wonder-blocks-data 11.0.16 → 12.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 (44) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/es/index.js +14 -12
  3. package/dist/hooks/use-hydratable-effect.d.ts +6 -6
  4. package/dist/index.js +14 -12
  5. package/dist/util/types.d.ts +6 -6
  6. package/package.json +3 -3
  7. package/src/hooks/use-hydratable-effect.ts +6 -7
  8. package/src/util/types.ts +6 -7
  9. package/tsconfig-build.tsbuildinfo +1 -1
  10. package/dist/components/data.js.flow +0 -63
  11. package/dist/components/gql-router.js.flow +0 -33
  12. package/dist/components/intercept-context.js.flow +0 -18
  13. package/dist/components/intercept-requests.js.flow +0 -51
  14. package/dist/components/track-data.js.flow +0 -16
  15. package/dist/hooks/use-cached-effect.js.flow +0 -83
  16. package/dist/hooks/use-gql-router-context.js.flow +0 -14
  17. package/dist/hooks/use-gql.js.flow +0 -28
  18. package/dist/hooks/use-hydratable-effect.js.flow +0 -122
  19. package/dist/hooks/use-request-interception.js.flow +0 -24
  20. package/dist/hooks/use-server-effect.js.flow +0 -49
  21. package/dist/hooks/use-shared-cache.js.flow +0 -42
  22. package/dist/index.js.flow +0 -47
  23. package/dist/util/data-error.js.flow +0 -62
  24. package/dist/util/get-gql-data-from-response.js.flow +0 -12
  25. package/dist/util/get-gql-request-id.js.flow +0 -16
  26. package/dist/util/gql-error.js.flow +0 -41
  27. package/dist/util/gql-router-context.js.flow +0 -10
  28. package/dist/util/gql-types.js.flow +0 -50
  29. package/dist/util/graphql-document-node-parser.js.flow +0 -29
  30. package/dist/util/graphql-types.js.flow +0 -30
  31. package/dist/util/hydration-cache-api.js.flow +0 -29
  32. package/dist/util/merge-gql-context.js.flow +0 -18
  33. package/dist/util/purge-caches.js.flow +0 -14
  34. package/dist/util/request-api.js.flow +0 -33
  35. package/dist/util/request-fulfillment.js.flow +0 -48
  36. package/dist/util/request-tracking.js.flow +0 -81
  37. package/dist/util/result-from-cache-response.js.flow +0 -14
  38. package/dist/util/scoped-in-memory-cache.js.flow +0 -56
  39. package/dist/util/serializable-in-memory-cache.js.flow +0 -25
  40. package/dist/util/ssr-cache.js.flow +0 -86
  41. package/dist/util/status.js.flow +0 -17
  42. package/dist/util/to-gql-operation.js.flow +0 -41
  43. package/dist/util/types.js.flow +0 -142
  44. package/src/util/graphql-types.js.flow +0 -30
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @khanacademy/wonder-blocks-data
2
2
 
3
+ ## 12.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 674a1e5c: POJOs have been replace with TS enums
8
+
9
+ ### Patch Changes
10
+
11
+ - 674a1e5c: We're no longer building flow types
12
+ - Updated dependencies [674a1e5c]
13
+ - Updated dependencies [674a1e5c]
14
+ - @khanacademy/wonder-blocks-core@6.0.0
15
+
3
16
  ## 11.0.16
4
17
 
5
18
  ### Patch Changes
package/dist/es/index.js CHANGED
@@ -3,12 +3,13 @@ import { KindError, clone, entries } from '@khanacademy/wonder-stuff-core';
3
3
  import * as React from 'react';
4
4
  import { useContext, useRef, useMemo, useCallback } from 'react';
5
5
 
6
- const FetchPolicy = {
7
- CacheBeforeNetwork: "CacheBeforeNetwork",
8
- CacheAndNetwork: "CacheAndNetwork",
9
- CacheOnly: "CacheOnly",
10
- NetworkOnly: "NetworkOnly"
11
- };
6
+ let FetchPolicy = function (FetchPolicy) {
7
+ FetchPolicy["CacheBeforeNetwork"] = "CacheBeforeNetwork";
8
+ FetchPolicy["CacheAndNetwork"] = "CacheAndNetwork";
9
+ FetchPolicy["CacheOnly"] = "CacheOnly";
10
+ FetchPolicy["NetworkOnly"] = "NetworkOnly";
11
+ return FetchPolicy;
12
+ }({});
12
13
 
13
14
  const DataErrors = Object.freeze({
14
15
  Unknown: "Unknown",
@@ -533,12 +534,13 @@ const useCachedEffect = (requestId, handler, options = {}) => {
533
534
  return [result, fetchRequest];
534
535
  };
535
536
 
536
- const WhenClientSide = {
537
- DoNotHydrate: "DoNotHydrate",
538
- ExecuteWhenNoResult: "ExecuteWhenNoResult",
539
- ExecuteWhenNoSuccessResult: "ExecuteWhenNoSuccessResult",
540
- AlwaysExecute: "AlwaysExecute"
541
- };
537
+ let WhenClientSide = function (WhenClientSide) {
538
+ WhenClientSide["DoNotHydrate"] = "DoNotHydrate";
539
+ WhenClientSide["ExecuteWhenNoResult"] = "ExecuteWhenNoResult";
540
+ WhenClientSide["ExecuteWhenNoSuccessResult"] = "ExecuteWhenNoSuccessResult";
541
+ WhenClientSide["AlwaysExecute"] = "AlwaysExecute";
542
+ return WhenClientSide;
543
+ }({});
542
544
  const DefaultScope = "useHydratableEffect";
543
545
  const useHydratableEffect = (requestId, handler, options = {}) => {
544
546
  const {
@@ -2,7 +2,7 @@ import type { Result, ValidCacheData } from "../util/types";
2
2
  /**
3
3
  * Policies to define how a hydratable effect should behave client-side.
4
4
  */
5
- export declare const WhenClientSide: {
5
+ export declare enum WhenClientSide {
6
6
  /**
7
7
  * The result from executing the effect server-side will not be hydrated.
8
8
  * The effect will always be executed client-side.
@@ -11,14 +11,14 @@ export declare const WhenClientSide: {
11
11
  * for properly hydrating this component (for example, the action invokes
12
12
  * Apollo which manages its own cache to ensure things render properly).
13
13
  */
14
- readonly DoNotHydrate: "DoNotHydrate";
14
+ DoNotHydrate = "DoNotHydrate",
15
15
  /**
16
16
  * The result from executing the effect server-side will be hydrated.
17
17
  * The effect will only execute client-side if there was no result to
18
18
  * be hydrated (i.e. both error and success hydration results prevent the
19
19
  * effect running client-side).
20
20
  */
21
- readonly ExecuteWhenNoResult: "ExecuteWhenNoResult";
21
+ ExecuteWhenNoResult = "ExecuteWhenNoResult",
22
22
  /**
23
23
  * The result from executing the effect server-side will be hydrated.
24
24
  * If the hydrated result is a success result, the effect will not be
@@ -26,14 +26,14 @@ export declare const WhenClientSide: {
26
26
  * If the hydrated result was not a success result, or there was no
27
27
  * hydrated result, the effect will not be executed.
28
28
  */
29
- readonly ExecuteWhenNoSuccessResult: "ExecuteWhenNoSuccessResult";
29
+ ExecuteWhenNoSuccessResult = "ExecuteWhenNoSuccessResult",
30
30
  /**
31
31
  * The result from executing the effect server-side will be hydrated.
32
32
  * The effect will always be executed client-side, regardless of the
33
33
  * hydrated result status.
34
34
  */
35
- readonly AlwaysExecute: "AlwaysExecute";
36
- };
35
+ AlwaysExecute = "AlwaysExecute"
36
+ }
37
37
  type HydratableEffectOptions<TData extends ValidCacheData> = {
38
38
  /**
39
39
  * How the hook should behave when rendering client-side for the first time.
package/dist/index.js CHANGED
@@ -26,12 +26,13 @@ function _interopNamespace(e) {
26
26
 
27
27
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
28
 
29
- const FetchPolicy = {
30
- CacheBeforeNetwork: "CacheBeforeNetwork",
31
- CacheAndNetwork: "CacheAndNetwork",
32
- CacheOnly: "CacheOnly",
33
- NetworkOnly: "NetworkOnly"
34
- };
29
+ let FetchPolicy = function (FetchPolicy) {
30
+ FetchPolicy["CacheBeforeNetwork"] = "CacheBeforeNetwork";
31
+ FetchPolicy["CacheAndNetwork"] = "CacheAndNetwork";
32
+ FetchPolicy["CacheOnly"] = "CacheOnly";
33
+ FetchPolicy["NetworkOnly"] = "NetworkOnly";
34
+ return FetchPolicy;
35
+ }({});
35
36
 
36
37
  const DataErrors = Object.freeze({
37
38
  Unknown: "Unknown",
@@ -556,12 +557,13 @@ const useCachedEffect = (requestId, handler, options = {}) => {
556
557
  return [result, fetchRequest];
557
558
  };
558
559
 
559
- const WhenClientSide = {
560
- DoNotHydrate: "DoNotHydrate",
561
- ExecuteWhenNoResult: "ExecuteWhenNoResult",
562
- ExecuteWhenNoSuccessResult: "ExecuteWhenNoSuccessResult",
563
- AlwaysExecute: "AlwaysExecute"
564
- };
560
+ let WhenClientSide = function (WhenClientSide) {
561
+ WhenClientSide["DoNotHydrate"] = "DoNotHydrate";
562
+ WhenClientSide["ExecuteWhenNoResult"] = "ExecuteWhenNoResult";
563
+ WhenClientSide["ExecuteWhenNoSuccessResult"] = "ExecuteWhenNoSuccessResult";
564
+ WhenClientSide["AlwaysExecute"] = "AlwaysExecute";
565
+ return WhenClientSide;
566
+ }({});
565
567
  const DefaultScope = "useHydratableEffect";
566
568
  const useHydratableEffect = (requestId, handler, options = {}) => {
567
569
  const {
@@ -2,26 +2,26 @@ import type { Metadata } from "@khanacademy/wonder-stuff-core";
2
2
  /**
3
3
  * Defines the various fetch policies that can be applied to requests.
4
4
  */
5
- export declare const FetchPolicy: {
5
+ export declare enum FetchPolicy {
6
6
  /**
7
7
  * If the data is in the cache, return that; otherwise, fetch from the
8
8
  * server.
9
9
  */
10
- readonly CacheBeforeNetwork: "CacheBeforeNetwork";
10
+ CacheBeforeNetwork = "CacheBeforeNetwork",
11
11
  /**
12
12
  * If the data is in the cache, return that; always fetch from the server
13
13
  * regardless of cache.
14
14
  */
15
- readonly CacheAndNetwork: "CacheAndNetwork";
15
+ CacheAndNetwork = "CacheAndNetwork",
16
16
  /**
17
17
  * If the data is in the cache, return that; otherwise, do nothing.
18
18
  */
19
- readonly CacheOnly: "CacheOnly";
19
+ CacheOnly = "CacheOnly",
20
20
  /**
21
21
  * Ignore any existing cached result; always fetch from the server.
22
22
  */
23
- readonly NetworkOnly: "NetworkOnly";
24
- };
23
+ NetworkOnly = "NetworkOnly"
24
+ }
25
25
  /**
26
26
  * Define what can be cached.
27
27
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@khanacademy/wonder-blocks-data",
3
- "version": "11.0.16",
3
+ "version": "12.0.0",
4
4
  "design": "v1",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -14,14 +14,14 @@
14
14
  },
15
15
  "dependencies": {
16
16
  "@babel/runtime": "^7.18.6",
17
- "@khanacademy/wonder-blocks-core": "^5.4.0"
17
+ "@khanacademy/wonder-blocks-core": "^6.0.0"
18
18
  },
19
19
  "peerDependencies": {
20
20
  "@khanacademy/wonder-stuff-core": "^1.2.2",
21
21
  "react": "16.14.0"
22
22
  },
23
23
  "devDependencies": {
24
- "wb-dev-build-settings": "^0.9.7"
24
+ "@khanacademy/wb-dev-build-settings": "^1.0.0"
25
25
  },
26
26
  "author": "",
27
27
  "license": "MIT"
@@ -10,8 +10,7 @@ import type {Result, ValidCacheData} from "../util/types";
10
10
  /**
11
11
  * Policies to define how a hydratable effect should behave client-side.
12
12
  */
13
- // TODO(FEI-5000): Convert to TS enum after all codebases have been migrated
14
- export const WhenClientSide = {
13
+ export enum WhenClientSide {
15
14
  /**
16
15
  * The result from executing the effect server-side will not be hydrated.
17
16
  * The effect will always be executed client-side.
@@ -20,7 +19,7 @@ export const WhenClientSide = {
20
19
  * for properly hydrating this component (for example, the action invokes
21
20
  * Apollo which manages its own cache to ensure things render properly).
22
21
  */
23
- DoNotHydrate: "DoNotHydrate" as const,
22
+ DoNotHydrate = "DoNotHydrate",
24
23
 
25
24
  /**
26
25
  * The result from executing the effect server-side will be hydrated.
@@ -28,7 +27,7 @@ export const WhenClientSide = {
28
27
  * be hydrated (i.e. both error and success hydration results prevent the
29
28
  * effect running client-side).
30
29
  */
31
- ExecuteWhenNoResult: "ExecuteWhenNoResult" as const,
30
+ ExecuteWhenNoResult = "ExecuteWhenNoResult",
32
31
 
33
32
  /**
34
33
  * The result from executing the effect server-side will be hydrated.
@@ -37,15 +36,15 @@ export const WhenClientSide = {
37
36
  * If the hydrated result was not a success result, or there was no
38
37
  * hydrated result, the effect will not be executed.
39
38
  */
40
- ExecuteWhenNoSuccessResult: "ExecuteWhenNoSuccessResult" as const,
39
+ ExecuteWhenNoSuccessResult = "ExecuteWhenNoSuccessResult",
41
40
 
42
41
  /**
43
42
  * The result from executing the effect server-side will be hydrated.
44
43
  * The effect will always be executed client-side, regardless of the
45
44
  * hydrated result status.
46
45
  */
47
- AlwaysExecute: "AlwaysExecute" as const,
48
- } as const;
46
+ AlwaysExecute = "AlwaysExecute",
47
+ }
49
48
 
50
49
  type HydratableEffectOptions<TData extends ValidCacheData> = {
51
50
  /**
package/src/util/types.ts CHANGED
@@ -3,30 +3,29 @@ import type {Metadata} from "@khanacademy/wonder-stuff-core";
3
3
  /**
4
4
  * Defines the various fetch policies that can be applied to requests.
5
5
  */
6
- // TODO(FEI-5000): Convert to TS enum after all codebases have been migrated
7
- export const FetchPolicy = {
6
+ export enum FetchPolicy {
8
7
  /**
9
8
  * If the data is in the cache, return that; otherwise, fetch from the
10
9
  * server.
11
10
  */
12
- CacheBeforeNetwork: "CacheBeforeNetwork" as const,
11
+ CacheBeforeNetwork = "CacheBeforeNetwork",
13
12
 
14
13
  /**
15
14
  * If the data is in the cache, return that; always fetch from the server
16
15
  * regardless of cache.
17
16
  */
18
- CacheAndNetwork: "CacheAndNetwork" as const,
17
+ CacheAndNetwork = "CacheAndNetwork",
19
18
 
20
19
  /**
21
20
  * If the data is in the cache, return that; otherwise, do nothing.
22
21
  */
23
- CacheOnly: "CacheOnly" as const,
22
+ CacheOnly = "CacheOnly",
24
23
 
25
24
  /**
26
25
  * Ignore any existing cached result; always fetch from the server.
27
26
  */
28
- NetworkOnly: "NetworkOnly" as const,
29
- } as const;
27
+ NetworkOnly = "NetworkOnly",
28
+ }
30
29
 
31
30
  /**
32
31
  * Define what can be cached.