@khanacademy/wonder-blocks-data 10.1.0 → 10.1.2

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 (180) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/components/data.d.ts +52 -0
  3. package/dist/components/data.js.flow +63 -0
  4. package/dist/components/gql-router.d.ts +24 -0
  5. package/dist/components/gql-router.js.flow +33 -0
  6. package/dist/components/intercept-context.d.ts +10 -0
  7. package/dist/components/intercept-context.js.flow +19 -0
  8. package/dist/components/intercept-requests.d.ts +42 -0
  9. package/dist/components/intercept-requests.js.flow +51 -0
  10. package/dist/components/track-data.d.ts +11 -0
  11. package/dist/components/track-data.js.flow +18 -0
  12. package/dist/es/index.js +184 -212
  13. package/dist/hooks/use-cached-effect.d.ts +70 -0
  14. package/dist/hooks/use-cached-effect.js.flow +85 -0
  15. package/dist/hooks/use-gql-router-context.d.ts +5 -0
  16. package/dist/hooks/use-gql-router-context.js.flow +15 -0
  17. package/dist/hooks/use-gql.d.ts +12 -0
  18. package/dist/hooks/use-gql.js.flow +29 -0
  19. package/dist/hooks/use-hydratable-effect.d.ts +102 -0
  20. package/dist/hooks/use-hydratable-effect.js.flow +125 -0
  21. package/dist/hooks/use-request-interception.d.ts +14 -0
  22. package/dist/hooks/use-request-interception.js.flow +25 -0
  23. package/dist/hooks/use-server-effect.d.ts +39 -0
  24. package/dist/hooks/use-server-effect.js.flow +51 -0
  25. package/dist/hooks/use-shared-cache.d.ts +32 -0
  26. package/dist/hooks/use-shared-cache.js.flow +43 -0
  27. package/dist/index.d.ts +24 -0
  28. package/dist/index.js +186 -217
  29. package/dist/index.js.flow +48 -2
  30. package/dist/util/data-error.d.ts +45 -0
  31. package/dist/util/data-error.js.flow +64 -0
  32. package/dist/util/get-gql-data-from-response.d.ts +4 -0
  33. package/dist/util/get-gql-data-from-response.js.flow +13 -0
  34. package/dist/util/get-gql-request-id.d.ts +5 -0
  35. package/dist/util/get-gql-request-id.js.flow +20 -0
  36. package/dist/util/gql-error.d.ts +28 -0
  37. package/dist/util/gql-error.js.flow +43 -0
  38. package/dist/util/gql-router-context.d.ts +3 -0
  39. package/dist/util/gql-router-context.js.flow +10 -0
  40. package/dist/util/gql-types.d.ts +34 -0
  41. package/dist/util/gql-types.js.flow +53 -0
  42. package/dist/util/graphql-document-node-parser.d.ts +18 -0
  43. package/dist/util/graphql-document-node-parser.js.flow +31 -0
  44. package/dist/util/graphql-types.d.ts +19 -0
  45. package/dist/util/graphql-types.js.flow +30 -0
  46. package/dist/util/hydration-cache-api.d.ts +17 -0
  47. package/dist/util/hydration-cache-api.js.flow +30 -0
  48. package/dist/util/merge-gql-context.d.ts +8 -0
  49. package/dist/util/merge-gql-context.js.flow +19 -0
  50. package/dist/util/purge-caches.d.ts +8 -0
  51. package/dist/util/purge-caches.js.flow +15 -0
  52. package/dist/util/request-api.d.ts +28 -0
  53. package/dist/util/request-api.js.flow +34 -0
  54. package/dist/util/request-fulfillment.d.ts +37 -0
  55. package/dist/util/request-fulfillment.js.flow +50 -0
  56. package/dist/util/request-tracking.d.ts +62 -0
  57. package/dist/util/request-tracking.js.flow +81 -0
  58. package/dist/util/result-from-cache-response.d.ts +5 -0
  59. package/dist/util/result-from-cache-response.js.flow +15 -0
  60. package/dist/util/scoped-in-memory-cache.d.ts +38 -0
  61. package/dist/util/scoped-in-memory-cache.js.flow +57 -0
  62. package/dist/util/serializable-in-memory-cache.d.ts +16 -0
  63. package/dist/util/serializable-in-memory-cache.js.flow +26 -0
  64. package/dist/util/ssr-cache.d.ts +51 -0
  65. package/dist/util/ssr-cache.js.flow +87 -0
  66. package/dist/util/status.d.ts +10 -0
  67. package/dist/util/status.js.flow +19 -0
  68. package/dist/util/to-gql-operation.d.ts +32 -0
  69. package/dist/util/to-gql-operation.js.flow +45 -0
  70. package/dist/util/types.d.ts +111 -0
  71. package/dist/util/types.js.flow +151 -0
  72. package/package.json +5 -6
  73. package/src/components/__tests__/{data.test.js → data.test.tsx} +42 -2
  74. package/src/components/__tests__/{gql-router.test.js → gql-router.test.tsx} +4 -5
  75. package/src/components/__tests__/{intercept-requests.test.js → intercept-requests.test.tsx} +2 -3
  76. package/src/components/__tests__/{track-data.test.js → track-data.test.tsx} +2 -3
  77. package/src/components/{data.js → data.ts} +11 -15
  78. package/src/components/{gql-router.js → gql-router.tsx} +12 -14
  79. package/src/components/{intercept-context.js → intercept-context.ts} +4 -3
  80. package/src/components/{intercept-requests.js → intercept-requests.tsx} +7 -8
  81. package/src/components/{track-data.js → track-data.tsx} +4 -5
  82. package/src/hooks/__tests__/{use-cached-effect.test.js → use-cached-effect.test.tsx} +55 -50
  83. package/src/hooks/__tests__/{use-gql-router-context.test.js → use-gql-router-context.test.tsx} +7 -7
  84. package/src/hooks/__tests__/{use-gql.test.js → use-gql.test.tsx} +20 -21
  85. package/src/hooks/__tests__/{use-hydratable-effect.test.js → use-hydratable-effect.test.ts} +42 -37
  86. package/src/hooks/__tests__/{use-request-interception.test.js → use-request-interception.test.tsx} +5 -3
  87. package/src/hooks/__tests__/{use-server-effect.test.js → use-server-effect.test.ts} +8 -2
  88. package/src/hooks/__tests__/{use-shared-cache.test.js → use-shared-cache.test.ts} +12 -12
  89. package/src/hooks/{use-cached-effect.js → use-cached-effect.ts} +27 -20
  90. package/src/hooks/{use-gql-router-context.js → use-gql-router-context.ts} +2 -3
  91. package/src/hooks/{use-gql.js → use-gql.ts} +5 -5
  92. package/src/hooks/{use-hydratable-effect.js → use-hydratable-effect.ts} +53 -58
  93. package/src/hooks/{use-request-interception.js → use-request-interception.ts} +4 -4
  94. package/src/hooks/{use-server-effect.js → use-server-effect.ts} +7 -9
  95. package/src/hooks/{use-shared-cache.js → use-shared-cache.ts} +13 -8
  96. package/src/{index.js → index.ts} +0 -1
  97. package/src/util/__tests__/{get-gql-data-from-response.test.js → get-gql-data-from-response.test.ts} +0 -1
  98. package/src/util/__tests__/{get-gql-request-id.test.js → get-gql-request-id.test.ts} +9 -11
  99. package/src/util/__tests__/{graphql-document-node-parser.test.js → graphql-document-node-parser.test.ts} +11 -12
  100. package/src/util/__tests__/{hydration-cache-api.test.js → hydration-cache-api.test.ts} +1 -2
  101. package/src/util/__tests__/{merge-gql-context.test.js → merge-gql-context.test.ts} +4 -5
  102. package/src/util/__tests__/{purge-caches.test.js → purge-caches.test.ts} +0 -1
  103. package/src/util/__tests__/{request-api.test.js → request-api.test.ts} +2 -2
  104. package/src/util/__tests__/{request-fulfillment.test.js → request-fulfillment.test.ts} +0 -1
  105. package/src/util/__tests__/{request-tracking.test.js → request-tracking.test.tsx} +13 -6
  106. package/src/util/__tests__/{result-from-cache-response.test.js → result-from-cache-response.test.ts} +2 -4
  107. package/src/util/__tests__/{scoped-in-memory-cache.test.js → scoped-in-memory-cache.test.ts} +4 -5
  108. package/src/util/__tests__/{serializable-in-memory-cache.test.js → serializable-in-memory-cache.test.ts} +7 -7
  109. package/src/util/__tests__/{ssr-cache.test.js → ssr-cache.test.ts} +3 -2
  110. package/src/util/__tests__/{to-gql-operation.test.js → to-gql-operation.test.ts} +2 -1
  111. package/src/util/{data-error.js → data-error.ts} +2 -3
  112. package/src/util/{get-gql-data-from-response.js → get-gql-data-from-response.ts} +1 -6
  113. package/src/util/{get-gql-request-id.js → get-gql-request-id.ts} +12 -16
  114. package/src/util/{gql-error.js → gql-error.ts} +2 -3
  115. package/src/util/gql-router-context.ts +6 -0
  116. package/src/util/{gql-types.js → gql-types.ts} +27 -23
  117. package/src/util/{graphql-document-node-parser.js → graphql-document-node-parser.ts} +6 -7
  118. package/src/util/graphql-types.ts +27 -0
  119. package/src/util/{hydration-cache-api.js → hydration-cache-api.ts} +4 -2
  120. package/src/util/{merge-gql-context.js → merge-gql-context.ts} +2 -2
  121. package/src/util/{purge-caches.js → purge-caches.ts} +0 -1
  122. package/src/util/{request-api.js → request-api.ts} +0 -1
  123. package/src/util/{request-fulfillment.js → request-fulfillment.ts} +13 -12
  124. package/src/util/{request-tracking.js → request-tracking.ts} +12 -13
  125. package/src/util/{result-from-cache-response.js → result-from-cache-response.ts} +3 -4
  126. package/src/util/{scoped-in-memory-cache.js → scoped-in-memory-cache.ts} +1 -2
  127. package/src/util/{serializable-in-memory-cache.js → serializable-in-memory-cache.ts} +2 -3
  128. package/src/util/{ssr-cache.js → ssr-cache.ts} +19 -18
  129. package/src/util/{status.js → status.ts} +4 -5
  130. package/src/util/{to-gql-operation.js → to-gql-operation.ts} +1 -2
  131. package/src/util/{types.js → types.ts} +39 -48
  132. package/tsconfig.json +11 -0
  133. package/tsconfig.tsbuildinfo +1 -0
  134. package/src/__docs__/_overview_.stories.mdx +0 -18
  135. package/src/__docs__/_overview_graphql.stories.mdx +0 -35
  136. package/src/__docs__/_overview_ssr_.stories.mdx +0 -185
  137. package/src/__docs__/_overview_testing_.stories.mdx +0 -123
  138. package/src/__docs__/exports.abort-inflight-requests.stories.mdx +0 -20
  139. package/src/__docs__/exports.data-error.stories.mdx +0 -23
  140. package/src/__docs__/exports.data-errors.stories.mdx +0 -23
  141. package/src/__docs__/exports.data.stories.mdx +0 -146
  142. package/src/__docs__/exports.fetch-tracked-requests.stories.mdx +0 -24
  143. package/src/__docs__/exports.get-gql-request-id.stories.mdx +0 -24
  144. package/src/__docs__/exports.gql-error.stories.mdx +0 -23
  145. package/src/__docs__/exports.gql-errors.stories.mdx +0 -20
  146. package/src/__docs__/exports.gql-router.stories.mdx +0 -29
  147. package/src/__docs__/exports.has-tracked-requests-to-be-fetched.stories.mdx +0 -20
  148. package/src/__docs__/exports.intercept-requests.stories.mdx +0 -69
  149. package/src/__docs__/exports.intialize-hydration-cache.stories.mdx +0 -29
  150. package/src/__docs__/exports.purge-caches.stories.mdx +0 -23
  151. package/src/__docs__/exports.purge-hydration-cache.stories.mdx +0 -24
  152. package/src/__docs__/exports.scoped-in-memory-cache.stories.mdx +0 -92
  153. package/src/__docs__/exports.serializable-in-memory-cache.stories.mdx +0 -112
  154. package/src/__docs__/exports.shared-cache.stories.mdx +0 -16
  155. package/src/__docs__/exports.status.stories.mdx +0 -31
  156. package/src/__docs__/exports.track-data.stories.mdx +0 -209
  157. package/src/__docs__/exports.use-cached-effect.stories.mdx +0 -44
  158. package/src/__docs__/exports.use-gql.stories.mdx +0 -41
  159. package/src/__docs__/exports.use-hydratable-effect.stories.mdx +0 -43
  160. package/src/__docs__/exports.use-server-effect.stories.mdx +0 -50
  161. package/src/__docs__/exports.use-shared-cache.stories.mdx +0 -30
  162. package/src/__docs__/exports.when-client-side.stories.mdx +0 -33
  163. package/src/__docs__/types.cached-response.stories.mdx +0 -29
  164. package/src/__docs__/types.error-options.stories.mdx +0 -21
  165. package/src/__docs__/types.fetch-policy.stories.mdx +0 -44
  166. package/src/__docs__/types.gql-context.stories.mdx +0 -20
  167. package/src/__docs__/types.gql-fetch-fn.stories.mdx +0 -24
  168. package/src/__docs__/types.gql-fetch-options.stories.mdx +0 -24
  169. package/src/__docs__/types.gql-operation-type.stories.mdx +0 -24
  170. package/src/__docs__/types.gql-operation.stories.mdx +0 -67
  171. package/src/__docs__/types.raw-scoped-cache.stories.mdx +0 -27
  172. package/src/__docs__/types.response-cache.stories.mdx +0 -33
  173. package/src/__docs__/types.result.stories.mdx +0 -39
  174. package/src/__docs__/types.scoped-cache.stories.mdx +0 -114
  175. package/src/__docs__/types.valid-cache-data.stories.mdx +0 -23
  176. package/src/util/gql-router-context.js +0 -6
  177. package/src/util/graphql-types.js +0 -30
  178. /package/src/hooks/__tests__/__snapshots__/{use-shared-cache.test.js.snap → use-shared-cache.test.ts.snap} +0 -0
  179. /package/src/util/__tests__/__snapshots__/{scoped-in-memory-cache.test.js.snap → scoped-in-memory-cache.test.ts.snap} +0 -0
  180. /package/src/util/__tests__/__snapshots__/{serializable-in-memory-cache.test.js.snap → serializable-in-memory-cache.test.ts.snap} +0 -0
@@ -1,2 +1,48 @@
1
- // @flow
2
- export * from "../src/index";
1
+ /**
2
+ * Flowtype definitions for index
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ declare export { FetchPolicy } from "./util/types";
9
+ export type {
10
+ ErrorOptions,
11
+ ResponseCache,
12
+ CachedResponse,
13
+ Result,
14
+ RawScopedCache,
15
+ ValidCacheData,
16
+ ScopedCache,
17
+ } from "./util/types";
18
+ declare export * from "./util/hydration-cache-api";
19
+ declare export * from "./util/request-api";
20
+ declare export { purgeCaches } from "./util/purge-caches";
21
+ declare export { default as TrackData } from "./components/track-data";
22
+ declare export { default as Data } from "./components/data";
23
+ declare export { default as InterceptRequests } from "./components/intercept-requests";
24
+ declare export { DataError, DataErrors } from "./util/data-error";
25
+ declare export { useServerEffect } from "./hooks/use-server-effect";
26
+ declare export { useCachedEffect } from "./hooks/use-cached-effect";
27
+ declare export { useSharedCache, SharedCache } from "./hooks/use-shared-cache";
28
+ declare export {
29
+ useHydratableEffect,
30
+ WhenClientSide,
31
+ } from "./hooks/use-hydratable-effect";
32
+ declare export { ScopedInMemoryCache } from "./util/scoped-in-memory-cache";
33
+ declare export { SerializableInMemoryCache } from "./util/serializable-in-memory-cache";
34
+ declare export { Status } from "./util/status";
35
+ declare export { getGqlRequestId } from "./util/get-gql-request-id";
36
+ declare export { getGqlDataFromResponse } from "./util/get-gql-data-from-response";
37
+ declare export { graphQLDocumentNodeParser } from "./util/graphql-document-node-parser";
38
+ declare export { toGqlOperation } from "./util/to-gql-operation";
39
+ declare export { GqlRouter } from "./components/gql-router";
40
+ declare export { useGql } from "./hooks/use-gql";
41
+ declare export { GqlError, GqlErrors } from "./util/gql-error";
42
+ export type {
43
+ GqlContext,
44
+ GqlOperation,
45
+ GqlOperationType,
46
+ GqlFetchOptions,
47
+ GqlFetchFn,
48
+ } from "./util/gql-types";
@@ -0,0 +1,45 @@
1
+ import { KindError } from "@khanacademy/wonder-stuff-core";
2
+ import type { ErrorOptions } from "./types";
3
+ /**
4
+ * Error kinds for DataError.
5
+ */
6
+ export declare const DataErrors: Readonly<{
7
+ /**
8
+ * The kind of error is not known.
9
+ */
10
+ Unknown: "Unknown";
11
+ /**
12
+ * The error is internal to the executing code.
13
+ */
14
+ Internal: "Internal";
15
+ /**
16
+ * There was a problem with the provided input.
17
+ */
18
+ InvalidInput: "InvalidInput";
19
+ /**
20
+ * A network error occurred.
21
+ */
22
+ Network: "Network";
23
+ /**
24
+ * There was a problem due to the state of the system not matching the
25
+ * requested operation or input.
26
+ */
27
+ NotAllowed: "NotAllowed";
28
+ /**
29
+ * Response could not be parsed.
30
+ */
31
+ Parse: "Parse";
32
+ /**
33
+ * An error that occurred during SSR and was hydrated from cache
34
+ */
35
+ Hydrated: "Hydrated";
36
+ }>;
37
+ /**
38
+ * An error from the Wonder Blocks Data API.
39
+ *
40
+ * Errors of this type will have names of the format:
41
+ * `${kind}DataError`
42
+ */
43
+ export declare class DataError extends KindError {
44
+ constructor(message: string, kind: typeof DataErrors[keyof typeof DataErrors], { metadata, cause }?: ErrorOptions);
45
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Flowtype definitions for data-error
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import { KindError } from "@khanacademy/wonder-stuff-core";
9
+ import type { ErrorOptions } from "./types";
10
+
11
+ /**
12
+ * Error kinds for DataError.
13
+ */
14
+ declare export var DataErrors: $ReadOnly<{
15
+ /**
16
+ * The kind of error is not known.
17
+ */
18
+ Unknown: "Unknown",
19
+
20
+ /**
21
+ * The error is internal to the executing code.
22
+ */
23
+ Internal: "Internal",
24
+
25
+ /**
26
+ * There was a problem with the provided input.
27
+ */
28
+ InvalidInput: "InvalidInput",
29
+
30
+ /**
31
+ * A network error occurred.
32
+ */
33
+ Network: "Network",
34
+
35
+ /**
36
+ * There was a problem due to the state of the system not matching the
37
+ * requested operation or input.
38
+ */
39
+ NotAllowed: "NotAllowed",
40
+
41
+ /**
42
+ * Response could not be parsed.
43
+ */
44
+ Parse: "Parse",
45
+
46
+ /**
47
+ * An error that occurred during SSR and was hydrated from cache
48
+ */
49
+ Hydrated: "Hydrated",
50
+ ...
51
+ }>;
52
+ /**
53
+ * An error from the Wonder Blocks Data API.
54
+ *
55
+ * Errors of this type will have names of the format:
56
+ * `${kind}DataError`
57
+ */
58
+ declare export class DataError extends KindError {
59
+ constructor(
60
+ message: string,
61
+ kind: $ElementType<typeof DataErrors, $Keys<typeof DataErrors>>,
62
+ x?: ErrorOptions
63
+ ): this;
64
+ }
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Validate a GQL operation response and extract the data.
3
+ */
4
+ export declare const getGqlDataFromResponse: <TData>(response: Response) => Promise<TData>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Flowtype definitions for get-gql-data-from-response
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ /**
9
+ * Validate a GQL operation response and extract the data.
10
+ */
11
+ declare export var getGqlDataFromResponse: <TData>(
12
+ response: Response
13
+ ) => Promise<TData>;
@@ -0,0 +1,5 @@
1
+ import type { GqlOperation, GqlContext } from "./gql-types";
2
+ /**
3
+ * Get an identifier for a given request.
4
+ */
5
+ export declare const getGqlRequestId: <TData, TVariables extends Record<any, any>>(operation: GqlOperation<TData, TVariables>, variables: TVariables | null | undefined, context: GqlContext) => string;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Flowtype definitions for get-gql-request-id
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import type { GqlOperation, GqlContext } from "./gql-types";
9
+
10
+ /**
11
+ * Get an identifier for a given request.
12
+ */
13
+ declare export var getGqlRequestId: <
14
+ TData,
15
+ TVariables: { [key: any]: any, ... }
16
+ >(
17
+ operation: GqlOperation<TData, TVariables>,
18
+ variables: TVariables | null | void,
19
+ context: GqlContext
20
+ ) => string;
@@ -0,0 +1,28 @@
1
+ import { KindError } from "@khanacademy/wonder-stuff-core";
2
+ import type { ErrorOptions } from "./types";
3
+ /**
4
+ * Error kinds for GqlError.
5
+ */
6
+ export declare const GqlErrors: Readonly<{
7
+ /**
8
+ * An internal framework error.
9
+ */
10
+ Internal: "Internal";
11
+ /**
12
+ * Response does not have the correct structure for a GraphQL response.
13
+ */
14
+ BadResponse: "BadResponse";
15
+ /**
16
+ * A valid GraphQL result with errors field in the payload.
17
+ */
18
+ ErrorResult: "ErrorResult";
19
+ }>;
20
+ /**
21
+ * An error from the GQL API.
22
+ *
23
+ * Errors of this type will have names of the format:
24
+ * `${kind}GqlError`
25
+ */
26
+ export declare class GqlError extends KindError {
27
+ constructor(message: string, kind: typeof GqlErrors[keyof typeof GqlErrors], { metadata, cause }?: ErrorOptions);
28
+ }
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Flowtype definitions for gql-error
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import { KindError } from "@khanacademy/wonder-stuff-core";
9
+ import type { ErrorOptions } from "./types";
10
+
11
+ /**
12
+ * Error kinds for GqlError.
13
+ */
14
+ declare export var GqlErrors: $ReadOnly<{
15
+ /**
16
+ * An internal framework error.
17
+ */
18
+ Internal: "Internal",
19
+
20
+ /**
21
+ * Response does not have the correct structure for a GraphQL response.
22
+ */
23
+ BadResponse: "BadResponse",
24
+
25
+ /**
26
+ * A valid GraphQL result with errors field in the payload.
27
+ */
28
+ ErrorResult: "ErrorResult",
29
+ ...
30
+ }>;
31
+ /**
32
+ * An error from the GQL API.
33
+ *
34
+ * Errors of this type will have names of the format:
35
+ * `${kind}GqlError`
36
+ */
37
+ declare export class GqlError extends KindError {
38
+ constructor(
39
+ message: string,
40
+ kind: $ElementType<typeof GqlErrors, $Keys<typeof GqlErrors>>,
41
+ x?: ErrorOptions
42
+ ): this;
43
+ }
@@ -0,0 +1,3 @@
1
+ import * as React from "react";
2
+ import type { GqlRouterConfiguration } from "./gql-types";
3
+ export declare const GqlRouterContext: React.Context<GqlRouterConfiguration<any> | null | undefined>;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Flowtype definitions for gql-router-context
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import * as React from "react";
9
+ import type { GqlRouterConfiguration } from "./gql-types";
10
+ declare export var GqlRouterContext: React.Context<GqlRouterConfiguration<any> | null | void>;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Operation types.
3
+ */
4
+ export type GqlOperationType = "mutation" | "query";
5
+ /**
6
+ * A GraphQL operation.
7
+ */
8
+ export type GqlOperation<TData, // TVariables is not used to define a field on this type, but it is used
9
+ TVariables extends object = Empty> = {
10
+ type: GqlOperationType;
11
+ id: string;
12
+ [key: string]: unknown;
13
+ };
14
+ export type GqlContext = {
15
+ [key: string]: string;
16
+ };
17
+ /**
18
+ * Functions that make fetches of GQL operations.
19
+ */
20
+ export type GqlFetchFn<TData, TVariables extends Record<any, any>, TContext extends GqlContext> = (operation: GqlOperation<TData, TVariables>, variables: TVariables | null | undefined, context: TContext) => Promise<Response>;
21
+ /**
22
+ * The configuration stored in the GqlRouterContext context.
23
+ */
24
+ export type GqlRouterConfiguration<TContext extends GqlContext> = {
25
+ fetch: GqlFetchFn<any, any, any>;
26
+ defaultContext: TContext;
27
+ };
28
+ /**
29
+ * Options for configuring a GQL fetch.
30
+ */
31
+ export type GqlFetchOptions<TVariables extends Record<any, any>, TContext extends GqlContext> = {
32
+ variables?: TVariables;
33
+ context?: Partial<TContext>;
34
+ };
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Flowtype definitions for gql-types
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ /**
9
+ * Operation types.
10
+ */
11
+ export type GqlOperationType = "mutation" | "query";
12
+ /**
13
+ * A GraphQL operation.
14
+ */
15
+ export type GqlOperation<TData, TVariables: { [key: string]: any } = Empty> = {
16
+ type: GqlOperationType,
17
+ id: string,
18
+ [key: string]: mixed,
19
+ };
20
+ export type GqlContext = {
21
+ [key: string]: string,
22
+ };
23
+ /**
24
+ * Functions that make fetches of GQL operations.
25
+ */
26
+ export type GqlFetchFn<
27
+ TData,
28
+ TVariables: { [key: any]: any, ... },
29
+ TContext: GqlContext
30
+ > = (
31
+ operation: GqlOperation<TData, TVariables>,
32
+ variables: TVariables | null | void,
33
+ context: TContext
34
+ ) => Promise<Response>;
35
+ /**
36
+ * The configuration stored in the GqlRouterContext context.
37
+ */
38
+ export type GqlRouterConfiguration<TContext: GqlContext> = {
39
+ fetch: GqlFetchFn<any, any, any>,
40
+ defaultContext: TContext,
41
+ ...
42
+ };
43
+ /**
44
+ * Options for configuring a GQL fetch.
45
+ */
46
+ export type GqlFetchOptions<
47
+ TVariables: { [key: any]: any, ... },
48
+ TContext: GqlContext
49
+ > = {
50
+ variables?: TVariables,
51
+ context?: $Rest<TContext, { ... }>,
52
+ ...
53
+ };
@@ -0,0 +1,18 @@
1
+ import type { DocumentNode, VariableDefinitionNode } from "./graphql-types";
2
+ export declare const DocumentTypes: Readonly<{
3
+ query: "query";
4
+ mutation: "mutation";
5
+ }>;
6
+ export type DocumentType = typeof DocumentTypes[keyof typeof DocumentTypes];
7
+ export interface IDocumentDefinition {
8
+ type: DocumentType;
9
+ name: string;
10
+ variables: ReadonlyArray<VariableDefinitionNode>;
11
+ }
12
+ /**
13
+ * Parse a GraphQL document node to determine some info about it.
14
+ *
15
+ * This is based on:
16
+ * https://github.com/apollographql/react-apollo/blob/3bc993b2ea91704bd6a2667f42d1940656c071ff/src/parser.ts
17
+ */
18
+ export declare function graphQLDocumentNodeParser(document: DocumentNode): IDocumentDefinition;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Flowtype definitions for graphql-document-node-parser
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import type { DocumentNode, VariableDefinitionNode } from "./graphql-types";
9
+ declare export var DocumentTypes: $ReadOnly<{
10
+ query: "query",
11
+ mutation: "mutation",
12
+ ...
13
+ }>;
14
+ export type DocumentType = $ElementType<
15
+ typeof DocumentTypes,
16
+ $Keys<typeof DocumentTypes>
17
+ >;
18
+ export interface IDocumentDefinition {
19
+ type: DocumentType;
20
+ name: string;
21
+ variables: $ReadOnlyArray<VariableDefinitionNode>;
22
+ }
23
+ /**
24
+ * Parse a GraphQL document node to determine some info about it.
25
+ *
26
+ * This is based on:
27
+ * https://github.com/apollographql/react-apollo/blob/3bc993b2ea91704bd6a2667f42d1940656c071ff/src/parser.ts
28
+ */
29
+ declare export function graphQLDocumentNodeParser(
30
+ document: DocumentNode
31
+ ): IDocumentDefinition;
@@ -0,0 +1,19 @@
1
+ export interface DefinitionNode {
2
+ readonly kind: string;
3
+ }
4
+ export type VariableDefinitionNode = {
5
+ readonly kind: "VariableDefinition";
6
+ };
7
+ export interface OperationDefinitionNode extends DefinitionNode {
8
+ readonly kind: "OperationDefinition";
9
+ readonly operation: string;
10
+ readonly variableDefinitions: ReadonlyArray<VariableDefinitionNode>;
11
+ readonly name?: {
12
+ readonly kind: unknown;
13
+ readonly value: string;
14
+ };
15
+ }
16
+ export type DocumentNode = {
17
+ readonly kind: "Document";
18
+ readonly definitions: ReadonlyArray<DefinitionNode>;
19
+ };
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Flowtype definitions for graphql-types
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ export interface DefinitionNode {
9
+ +kind: string;
10
+ }
11
+ export type VariableDefinitionNode = {
12
+ +kind: "VariableDefinition",
13
+ ...
14
+ };
15
+ export type OperationDefinitionNode = {
16
+ +kind: "OperationDefinition",
17
+ +operation: string,
18
+ +variableDefinitions: $ReadOnlyArray<VariableDefinitionNode>,
19
+ +name?: {
20
+ +kind: mixed,
21
+ +value: string,
22
+ ...
23
+ },
24
+ ...
25
+ } & DefinitionNode;
26
+ export type DocumentNode = {
27
+ +kind: "Document",
28
+ +definitions: $ReadOnlyArray<DefinitionNode>,
29
+ ...
30
+ };
@@ -0,0 +1,17 @@
1
+ import type { ValidCacheData, CachedResponse, ResponseCache } from "./types";
2
+ /**
3
+ * Initialize the hydration cache.
4
+ *
5
+ * @param {ResponseCache} source The cache content to use for initializing the
6
+ * cache.
7
+ * @throws {Error} If the cache is already initialized.
8
+ */
9
+ export declare const initializeHydrationCache: (source: ResponseCache) => void;
10
+ /**
11
+ * Purge cached hydration responses that match the given predicate.
12
+ *
13
+ * @param {(id: string) => boolean} [predicate] The predicate to match against
14
+ * the cached hydration responses. If no predicate is provided, all cached
15
+ * hydration responses will be purged.
16
+ */
17
+ export declare const purgeHydrationCache: (predicate?: ((key: string, cacheEntry?: Readonly<CachedResponse<ValidCacheData>> | null | undefined) => boolean) | undefined) => void;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Flowtype definitions for hydration-cache-api
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import type { ValidCacheData, CachedResponse, ResponseCache } from "./types";
9
+
10
+ /**
11
+ * Initialize the hydration cache.
12
+ * @param {ResponseCache} source The cache content to use for initializing the
13
+ * cache.
14
+ * @throws {Error} If the cache is already initialized.
15
+ */
16
+ declare export var initializeHydrationCache: (source: ResponseCache) => void;
17
+ /**
18
+ * Purge cached hydration responses that match the given predicate.
19
+ * @param {(id: string) => boolean} [predicate] The predicate to match against
20
+ * the cached hydration responses. If no predicate is provided, all cached
21
+ * hydration responses will be purged.
22
+ */
23
+ declare export var purgeHydrationCache: (
24
+ predicate?:
25
+ | ((
26
+ key: string,
27
+ cacheEntry?: $ReadOnly<CachedResponse<ValidCacheData>> | null | void
28
+ ) => boolean)
29
+ | void
30
+ ) => void;
@@ -0,0 +1,8 @@
1
+ import type { GqlContext } from "./gql-types";
2
+ /**
3
+ * Construct a complete GqlContext from current defaults and a partial context.
4
+ *
5
+ * Values in the partial context that are `undefined` will be ignored.
6
+ * Values in the partial context that are `null` will be deleted.
7
+ */
8
+ export declare const mergeGqlContext: <TContext extends GqlContext>(defaultContext: TContext, overrides: Partial<TContext>) => TContext;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Flowtype definitions for merge-gql-context
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import type { GqlContext } from "./gql-types";
9
+
10
+ /**
11
+ * Construct a complete GqlContext from current defaults and a partial context.
12
+ *
13
+ * Values in the partial context that are `undefined` will be ignored.
14
+ * Values in the partial context that are `null` will be deleted.
15
+ */
16
+ declare export var mergeGqlContext: <TContext: GqlContext>(
17
+ defaultContext: TContext,
18
+ overrides: $Rest<TContext, { ... }>
19
+ ) => TContext;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Purge all caches managed by Wonder Blocks Data.
3
+ *
4
+ * This is a convenience method that purges the shared cache and the hydration
5
+ * cache. It is useful for testing purposes to avoid having to reason about
6
+ * which caches may have been used during a given test run.
7
+ */
8
+ export declare const purgeCaches: () => void;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Flowtype definitions for purge-caches
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ /**
9
+ * Purge all caches managed by Wonder Blocks Data.
10
+ *
11
+ * This is a convenience method that purges the shared cache and the hydration
12
+ * cache. It is useful for testing purposes to avoid having to reason about
13
+ * which caches may have been used during a given test run.
14
+ */
15
+ declare export var purgeCaches: () => void;
@@ -0,0 +1,28 @@
1
+ import type { ResponseCache } from "./types";
2
+ /**
3
+ * Fetches all tracked data requests.
4
+ *
5
+ * This is for use with the `TrackData` component during server-side rendering.
6
+ *
7
+ * @throws {Error} If executed outside of server-side rendering.
8
+ * @returns {Promise<void>} A promise that resolves when all tracked requests
9
+ * have been fetched.
10
+ */
11
+ export declare const fetchTrackedRequests: () => Promise<ResponseCache>;
12
+ /**
13
+ * Indicate if there are tracked requests waiting to be fetched.
14
+ *
15
+ * This is used in conjunction with `TrackData`.
16
+ *
17
+ * @throws {Error} If executed outside of server-side rendering.
18
+ * @returns {boolean} `true` if there are unfetched tracked requests;
19
+ * otherwise, `false`.
20
+ */
21
+ export declare const hasTrackedRequestsToBeFetched: () => boolean;
22
+ /**
23
+ * Abort all in-flight requests.
24
+ *
25
+ * This aborts all requests currently inflight via our default request
26
+ * fulfillment.
27
+ */
28
+ export declare const abortInflightRequests: () => void;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Flowtype definitions for request-api
3
+ * Generated by Flowgen from a Typescript Definition
4
+ * Flowgen v1.21.0
5
+ * @flow
6
+ */
7
+
8
+ import type { ResponseCache } from "./types";
9
+
10
+ /**
11
+ * Fetches all tracked data requests.
12
+ *
13
+ * This is for use with the `TrackData` component during server-side rendering.
14
+ * @throws {Error} If executed outside of server-side rendering.
15
+ * @returns {Promise<void>} A promise that resolves when all tracked requests
16
+ * have been fetched.
17
+ */
18
+ declare export var fetchTrackedRequests: () => Promise<ResponseCache>;
19
+ /**
20
+ * Indicate if there are tracked requests waiting to be fetched.
21
+ *
22
+ * This is used in conjunction with `TrackData`.
23
+ * @throws {Error} If executed outside of server-side rendering.
24
+ * @returns {boolean} `true` if there are unfetched tracked requests;
25
+ * otherwise, `false`.
26
+ */
27
+ declare export var hasTrackedRequestsToBeFetched: () => boolean;
28
+ /**
29
+ * Abort all in-flight requests.
30
+ *
31
+ * This aborts all requests currently inflight via our default request
32
+ * fulfillment.
33
+ */
34
+ declare export var abortInflightRequests: () => void;