@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.
- package/CHANGELOG.md +13 -0
- package/dist/es/index.js +14 -12
- package/dist/hooks/use-hydratable-effect.d.ts +6 -6
- package/dist/index.js +14 -12
- package/dist/util/types.d.ts +6 -6
- package/package.json +3 -3
- package/src/hooks/use-hydratable-effect.ts +6 -7
- package/src/util/types.ts +6 -7
- package/tsconfig-build.tsbuildinfo +1 -1
- package/dist/components/data.js.flow +0 -63
- package/dist/components/gql-router.js.flow +0 -33
- package/dist/components/intercept-context.js.flow +0 -18
- package/dist/components/intercept-requests.js.flow +0 -51
- package/dist/components/track-data.js.flow +0 -16
- package/dist/hooks/use-cached-effect.js.flow +0 -83
- package/dist/hooks/use-gql-router-context.js.flow +0 -14
- package/dist/hooks/use-gql.js.flow +0 -28
- package/dist/hooks/use-hydratable-effect.js.flow +0 -122
- package/dist/hooks/use-request-interception.js.flow +0 -24
- package/dist/hooks/use-server-effect.js.flow +0 -49
- package/dist/hooks/use-shared-cache.js.flow +0 -42
- package/dist/index.js.flow +0 -47
- package/dist/util/data-error.js.flow +0 -62
- package/dist/util/get-gql-data-from-response.js.flow +0 -12
- package/dist/util/get-gql-request-id.js.flow +0 -16
- package/dist/util/gql-error.js.flow +0 -41
- package/dist/util/gql-router-context.js.flow +0 -10
- package/dist/util/gql-types.js.flow +0 -50
- package/dist/util/graphql-document-node-parser.js.flow +0 -29
- package/dist/util/graphql-types.js.flow +0 -30
- package/dist/util/hydration-cache-api.js.flow +0 -29
- package/dist/util/merge-gql-context.js.flow +0 -18
- package/dist/util/purge-caches.js.flow +0 -14
- package/dist/util/request-api.js.flow +0 -33
- package/dist/util/request-fulfillment.js.flow +0 -48
- package/dist/util/request-tracking.js.flow +0 -81
- package/dist/util/result-from-cache-response.js.flow +0 -14
- package/dist/util/scoped-in-memory-cache.js.flow +0 -56
- package/dist/util/serializable-in-memory-cache.js.flow +0 -25
- package/dist/util/ssr-cache.js.flow +0 -86
- package/dist/util/status.js.flow +0 -17
- package/dist/util/to-gql-operation.js.flow +0 -41
- package/dist/util/types.js.flow +0 -142
- 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
|
-
|
|
7
|
-
CacheBeforeNetwork
|
|
8
|
-
CacheAndNetwork
|
|
9
|
-
CacheOnly
|
|
10
|
-
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
|
-
|
|
537
|
-
DoNotHydrate
|
|
538
|
-
ExecuteWhenNoResult
|
|
539
|
-
ExecuteWhenNoSuccessResult
|
|
540
|
-
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
30
|
-
CacheBeforeNetwork
|
|
31
|
-
CacheAndNetwork
|
|
32
|
-
CacheOnly
|
|
33
|
-
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
|
-
|
|
560
|
-
DoNotHydrate
|
|
561
|
-
ExecuteWhenNoResult
|
|
562
|
-
ExecuteWhenNoSuccessResult
|
|
563
|
-
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 {
|
package/dist/util/types.d.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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
|
-
|
|
15
|
+
CacheAndNetwork = "CacheAndNetwork",
|
|
16
16
|
/**
|
|
17
17
|
* If the data is in the cache, return that; otherwise, do nothing.
|
|
18
18
|
*/
|
|
19
|
-
|
|
19
|
+
CacheOnly = "CacheOnly",
|
|
20
20
|
/**
|
|
21
21
|
* Ignore any existing cached result; always fetch from the server.
|
|
22
22
|
*/
|
|
23
|
-
|
|
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": "
|
|
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": "^
|
|
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.
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
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
|
|
48
|
-
}
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
22
|
+
CacheOnly = "CacheOnly",
|
|
24
23
|
|
|
25
24
|
/**
|
|
26
25
|
* Ignore any existing cached result; always fetch from the server.
|
|
27
26
|
*/
|
|
28
|
-
NetworkOnly
|
|
29
|
-
}
|
|
27
|
+
NetworkOnly = "NetworkOnly",
|
|
28
|
+
}
|
|
30
29
|
|
|
31
30
|
/**
|
|
32
31
|
* Define what can be cached.
|