react-fate 0.1.3 → 1.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/README.md +810 -129
- package/docs/api/functions/FateClient.md +23 -0
- package/docs/api/functions/clientRoot.md +27 -0
- package/docs/api/functions/createClient.md +21 -0
- package/docs/api/functions/createHTTPTransport.md +51 -0
- package/docs/api/functions/createTRPCTransport.md +46 -0
- package/docs/api/functions/mutation.md +32 -0
- package/docs/api/functions/useFateClient.md +17 -0
- package/docs/api/functions/useListView.md +28 -0
- package/docs/api/functions/useLiveListView.md +28 -0
- package/docs/api/functions/useLiveView.md +38 -0
- package/docs/api/functions/useRequest.md +38 -0
- package/docs/api/functions/useView.md +37 -0
- package/docs/api/functions/view.md +26 -0
- package/docs/api/index.md +35 -0
- package/docs/api/type-aliases/ConnectionRef.md +13 -0
- package/docs/api/type-aliases/InferFateAPI.md +11 -0
- package/docs/api/type-aliases/ViewRef.md +13 -0
- package/docs/api/variables/toEntityId.md +21 -0
- package/docs/guide/actions.md +263 -0
- package/docs/guide/core-concepts.md +22 -0
- package/docs/guide/getting-started.md +57 -0
- package/docs/guide/list-views.md +86 -0
- package/docs/guide/live-views.md +245 -0
- package/docs/guide/requests.md +130 -0
- package/docs/guide/server-integration.md +630 -0
- package/docs/guide/views.md +278 -0
- package/docs/guide/void-integration.md +167 -0
- package/docs/index.md +4 -0
- package/lib/cli.d.mts +1 -1
- package/lib/cli.mjs +1 -2
- package/lib/client.d.mts +7 -0
- package/lib/client.mjs +2 -0
- package/lib/index.d.mts +41 -17
- package/lib/index.mjs +96 -46
- package/lib/vite.d.mts +12 -0
- package/lib/vite.mjs +8 -0
- package/package.json +17 -6
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Function: FateClient()
|
|
2
|
+
|
|
3
|
+
> **FateClient**(`__namedParameters`): `Element`
|
|
4
|
+
|
|
5
|
+
Defined in: [packages/react-fate/src/context.tsx:17](https://github.com/nkzw-tech/fate/blob/17081c4f677e224e55b75d9a31bd6e0a7ee94af1/packages/react-fate/src/context.tsx#L17)
|
|
6
|
+
|
|
7
|
+
Provider component that supplies a configured `FateClient` to React hooks.
|
|
8
|
+
|
|
9
|
+
## Parameters
|
|
10
|
+
|
|
11
|
+
### \_\_namedParameters
|
|
12
|
+
|
|
13
|
+
#### children
|
|
14
|
+
|
|
15
|
+
`ReactNode`
|
|
16
|
+
|
|
17
|
+
#### client
|
|
18
|
+
|
|
19
|
+
`FateClient`\<`any`, `any`\>
|
|
20
|
+
|
|
21
|
+
## Returns
|
|
22
|
+
|
|
23
|
+
`Element`
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Function: clientRoot()
|
|
2
|
+
|
|
3
|
+
> **clientRoot**\<`Result`, `Type`\>(`type`): `RootDefinition`\<`Type`, `Result`\>
|
|
4
|
+
|
|
5
|
+
Defined in: packages/fate/lib/index.d.mts:69
|
|
6
|
+
|
|
7
|
+
Defines a root query for an entity type, capturing the response shape.
|
|
8
|
+
|
|
9
|
+
## Type Parameters
|
|
10
|
+
|
|
11
|
+
### Result
|
|
12
|
+
|
|
13
|
+
`Result`
|
|
14
|
+
|
|
15
|
+
### Type
|
|
16
|
+
|
|
17
|
+
`Type` *extends* `string`
|
|
18
|
+
|
|
19
|
+
## Parameters
|
|
20
|
+
|
|
21
|
+
### type
|
|
22
|
+
|
|
23
|
+
`Type`
|
|
24
|
+
|
|
25
|
+
## Returns
|
|
26
|
+
|
|
27
|
+
`RootDefinition`\<`Type`, `Result`\>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Function: createClient()
|
|
2
|
+
|
|
3
|
+
> **createClient**\<`T`\>(`options`): `FateClient`\<`T`\[`0`\], `T`\[`1`\]\>
|
|
4
|
+
|
|
5
|
+
Defined in: packages/fate/lib/types-Dz46PXr3.d.mts:973
|
|
6
|
+
|
|
7
|
+
## Type Parameters
|
|
8
|
+
|
|
9
|
+
### T
|
|
10
|
+
|
|
11
|
+
`T` *extends* \[`FateRoots`, `FateMutations`\] = \[`Record`\<`never`, `RootDefinition`\<`any`, `any`\>\>, `Record`\<`never`, `MutationDefinition`\<`any`, `any`, `any`\>\>\]
|
|
12
|
+
|
|
13
|
+
## Parameters
|
|
14
|
+
|
|
15
|
+
### options
|
|
16
|
+
|
|
17
|
+
`FateClientOptions`\<`T`\[`0`\], `T`\[`1`\]\>
|
|
18
|
+
|
|
19
|
+
## Returns
|
|
20
|
+
|
|
21
|
+
`FateClient`\<`T`\[`0`\], `T`\[`1`\]\>
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Function: createHTTPTransport()
|
|
2
|
+
|
|
3
|
+
> **createHTTPTransport**\<`API`, `Mutations`\>(`__namedParameters`): `Transport`\<`Mutations`\>
|
|
4
|
+
|
|
5
|
+
Defined in: packages/fate/lib/index.d.mts:47
|
|
6
|
+
|
|
7
|
+
## Type Parameters
|
|
8
|
+
|
|
9
|
+
### API
|
|
10
|
+
|
|
11
|
+
`API` *extends* `FateAPIShape`
|
|
12
|
+
|
|
13
|
+
### Mutations
|
|
14
|
+
|
|
15
|
+
`Mutations` *extends* `TransportMutations` = `MutationMapFromAPI`\<`API`\>
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
### \_\_namedParameters
|
|
20
|
+
|
|
21
|
+
#### eventSource?
|
|
22
|
+
|
|
23
|
+
`EventSourceConstructor`
|
|
24
|
+
|
|
25
|
+
#### fetch?
|
|
26
|
+
|
|
27
|
+
`FetchLike`
|
|
28
|
+
|
|
29
|
+
#### headers?
|
|
30
|
+
|
|
31
|
+
`HeadersFactory`
|
|
32
|
+
|
|
33
|
+
#### live?
|
|
34
|
+
|
|
35
|
+
`boolean` \| `LiveConnector`
|
|
36
|
+
|
|
37
|
+
#### liveRetryMs?
|
|
38
|
+
|
|
39
|
+
`number`
|
|
40
|
+
|
|
41
|
+
#### liveUrl?
|
|
42
|
+
|
|
43
|
+
`string` \| `URL`
|
|
44
|
+
|
|
45
|
+
#### url
|
|
46
|
+
|
|
47
|
+
`string` \| `URL`
|
|
48
|
+
|
|
49
|
+
## Returns
|
|
50
|
+
|
|
51
|
+
`Transport`\<`Mutations`\>
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Function: createTRPCTransport()
|
|
2
|
+
|
|
3
|
+
> **createTRPCTransport**\<`AppRouter`, `Mutations`\>(`__namedParameters`): `Transport`\<`MutationMapFromResolvers`\<`Mutations`\>\>
|
|
4
|
+
|
|
5
|
+
Defined in: packages/fate/lib/types-Dz46PXr3.d.mts:709
|
|
6
|
+
|
|
7
|
+
Builds a `Transport` backed by a tRPC client using the configured resolvers
|
|
8
|
+
for by-id queries, lists, and mutations.
|
|
9
|
+
|
|
10
|
+
## Type Parameters
|
|
11
|
+
|
|
12
|
+
### AppRouter
|
|
13
|
+
|
|
14
|
+
`AppRouter` *extends* `AnyRouter`
|
|
15
|
+
|
|
16
|
+
### Mutations
|
|
17
|
+
|
|
18
|
+
`Mutations` *extends* `TRPCMutationResolvers`\<`AppRouter`\> = `EmptyMutationResolvers`\<`AppRouter`\>
|
|
19
|
+
|
|
20
|
+
## Parameters
|
|
21
|
+
|
|
22
|
+
### \_\_namedParameters
|
|
23
|
+
|
|
24
|
+
#### byId
|
|
25
|
+
|
|
26
|
+
`TRPCByIdResolvers`\<`AppRouter`\>
|
|
27
|
+
|
|
28
|
+
#### client
|
|
29
|
+
|
|
30
|
+
`TRPCClient`\<`AppRouter`\>
|
|
31
|
+
|
|
32
|
+
#### lists?
|
|
33
|
+
|
|
34
|
+
`TRPCListResolvers`\<`AppRouter`\>
|
|
35
|
+
|
|
36
|
+
#### mutations?
|
|
37
|
+
|
|
38
|
+
`Mutations`
|
|
39
|
+
|
|
40
|
+
#### queries?
|
|
41
|
+
|
|
42
|
+
`TRPCQueryResolvers`\<`AppRouter`\>
|
|
43
|
+
|
|
44
|
+
## Returns
|
|
45
|
+
|
|
46
|
+
`Transport`\<`MutationMapFromResolvers`\<`Mutations`\>\>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Function: mutation()
|
|
2
|
+
|
|
3
|
+
> **mutation**\<`T`, `I`, `R`\>(`entity`): `MutationDefinition`\<`T`, `I`, `R`\>
|
|
4
|
+
|
|
5
|
+
Defined in: packages/fate/lib/types-Dz46PXr3.d.mts:980
|
|
6
|
+
|
|
7
|
+
Defines a mutation for a given entity type, preserving the input and output
|
|
8
|
+
types for transports.
|
|
9
|
+
|
|
10
|
+
## Type Parameters
|
|
11
|
+
|
|
12
|
+
### T
|
|
13
|
+
|
|
14
|
+
`T` *extends* `Entity`
|
|
15
|
+
|
|
16
|
+
### I
|
|
17
|
+
|
|
18
|
+
`I`
|
|
19
|
+
|
|
20
|
+
### R
|
|
21
|
+
|
|
22
|
+
`R`
|
|
23
|
+
|
|
24
|
+
## Parameters
|
|
25
|
+
|
|
26
|
+
### entity
|
|
27
|
+
|
|
28
|
+
`T`\[`"__typename"`\]
|
|
29
|
+
|
|
30
|
+
## Returns
|
|
31
|
+
|
|
32
|
+
`MutationDefinition`\<`T`, `I`, `R`\>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Function: useFateClient()
|
|
2
|
+
|
|
3
|
+
> **useFateClient**\<`T`\>(): `FateClient`\<`T`\[`0`\], `T`\[`1`\]\>
|
|
4
|
+
|
|
5
|
+
Defined in: [packages/react-fate/src/context.tsx:30](https://github.com/nkzw-tech/fate/blob/17081c4f677e224e55b75d9a31bd6e0a7ee94af1/packages/react-fate/src/context.tsx#L30)
|
|
6
|
+
|
|
7
|
+
Returns the nearest `FateClient` from context.
|
|
8
|
+
|
|
9
|
+
## Type Parameters
|
|
10
|
+
|
|
11
|
+
### T
|
|
12
|
+
|
|
13
|
+
`T` *extends* \[\{ `categories`: `RootDefinition`\<`"Category"`, `ConnectionResult`\<\{\[`key`: `string`\]: `any`; \}\>\>; `category`: `RootDefinition`\<`"Category"`, `Category`[]\>; `comment`: `RootDefinition`\<`"Comment"`, `Comment`[]\>; `commentSearch`: `RootDefinition`\<`"Comment"`, `ConnectionResult`\<\{\[`key`: `string`\]: `any`; \}\> & `ConnectionResult`\<`AnyRecord`\>\>; `event`: `RootDefinition`\<`"Event"`, `Event`[]\>; `eventAttendee`: `RootDefinition`\<`"EventAttendee"`, `EventAttendee`[]\>; `events`: `RootDefinition`\<`"Event"`, `ConnectionResult`\<\{\[`key`: `string`\]: `any`; \}\>\>; `post`: `RootDefinition`\<`"Post"`, `Post`[]\>; `posts`: `RootDefinition`\<`"Post"`, `ConnectionResult`\<\{\[`key`: `string`\]: `any`; \}\>\>; `tag`: `RootDefinition`\<`"Tag"`, `Tag`[]\>; `user`: `RootDefinition`\<`"User"`, `User`[]\>; `viewer`: `RootDefinition`\<`"User"`, `object` & `AnyRecord` \| `null`\>; \}, \{ `comment.add`: `MutationDefinition`\<`Comment`, \{ `content`: `string`; `postId`: `string`; \}, `object` & `ItemRecord` & `object` & `object`\>; `comment.delete`: `MutationDefinition`\<`Comment`, \{ `id`: `string`; \}, `object` & `ItemRecord` & `object` & `object`\>; `post.add`: `MutationDefinition`\<`Post`, \{ `content`: `string`; `title`: `string`; \}, `Post`\>; `post.like`: `MutationDefinition`\<`Post`, \{ `error?`: `"boundary"` \| `"callSite"`; `id`: `string`; `slow?`: `boolean`; \}, `Post`\>; `post.unlike`: `MutationDefinition`\<`Post`, \{ `id`: `string`; \}, `Post`\>; `user.update`: `MutationDefinition`\<`User`, \{ `name`: `string`; \}, `AnyRecord`\>; \}\] = \[\{ `categories`: `RootDefinition`\<`"Category"`, `ConnectionResult`\<\{\[`key`: `string`\]: `any`; \}\>\>; `category`: `RootDefinition`\<`"Category"`, `Category`[]\>; `comment`: `RootDefinition`\<`"Comment"`, `Comment`[]\>; `commentSearch`: `RootDefinition`\<`"Comment"`, `ConnectionResult`\<\{\[`key`: `string`\]: `any`; \}\> & `ConnectionResult`\<`AnyRecord`\>\>; `event`: `RootDefinition`\<`"Event"`, `Event`[]\>; `eventAttendee`: `RootDefinition`\<`"EventAttendee"`, `EventAttendee`[]\>; `events`: `RootDefinition`\<`"Event"`, `ConnectionResult`\<\{\[`key`: `string`\]: `any`; \}\>\>; `post`: `RootDefinition`\<`"Post"`, `Post`[]\>; `posts`: `RootDefinition`\<`"Post"`, `ConnectionResult`\<\{\[`key`: `string`\]: `any`; \}\>\>; `tag`: `RootDefinition`\<`"Tag"`, `Tag`[]\>; `user`: `RootDefinition`\<`"User"`, `User`[]\>; `viewer`: `RootDefinition`\<`"User"`, `object` & `AnyRecord` \| `null`\>; \}, \{ `comment.add`: `MutationDefinition`\<`Comment`, \{ `content`: `string`; `postId`: `string`; \}, `object` & `ItemRecord` & `object` & `object`\>; `comment.delete`: `MutationDefinition`\<`Comment`, \{ `id`: `string`; \}, `object` & `ItemRecord` & `object` & `object`\>; `post.add`: `MutationDefinition`\<`Post`, \{ `content`: `string`; `title`: `string`; \}, `Post`\>; `post.like`: `MutationDefinition`\<`Post`, \{ `error?`: `"boundary"` \| `"callSite"`; `id`: `string`; `slow?`: `boolean`; \}, `Post`\>; `post.unlike`: `MutationDefinition`\<`Post`, \{ `id`: `string`; \}, `Post`\>; `user.update`: `MutationDefinition`\<`User`, \{ `name`: `string`; \}, `AnyRecord`\>; \}\]
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
`FateClient`\<`T`\[`0`\], `T`\[`1`\]\>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Function: useListView()
|
|
2
|
+
|
|
3
|
+
> **useListView**\<`C`\>(`selection`, `connection`): \[`ConnectionItems`\<`NonNullable`\<`C`\>\>, `LoadMoreFn` \| `null`, `LoadMoreFn` \| `null`\]
|
|
4
|
+
|
|
5
|
+
Defined in: [packages/react-fate/src/useListView.tsx:16](https://github.com/nkzw-tech/fate/blob/17081c4f677e224e55b75d9a31bd6e0a7ee94af1/packages/react-fate/src/useListView.tsx#L16)
|
|
6
|
+
|
|
7
|
+
Subscribes to a connection field, returning the current items and pagination
|
|
8
|
+
helpers to load the next or previous page.
|
|
9
|
+
|
|
10
|
+
## Type Parameters
|
|
11
|
+
|
|
12
|
+
### C
|
|
13
|
+
|
|
14
|
+
`C` *extends* \{ `items?`: readonly `any`[]; `pagination?`: `Pagination`; \} \| `null` \| `undefined`
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
### selection
|
|
19
|
+
|
|
20
|
+
`ConnectionSelection`
|
|
21
|
+
|
|
22
|
+
### connection
|
|
23
|
+
|
|
24
|
+
`C`
|
|
25
|
+
|
|
26
|
+
## Returns
|
|
27
|
+
|
|
28
|
+
\[`ConnectionItems`\<`NonNullable`\<`C`\>\>, `LoadMoreFn` \| `null`, `LoadMoreFn` \| `null`\]
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Function: useLiveListView()
|
|
2
|
+
|
|
3
|
+
> **useLiveListView**\<`C`\>(`selection`, `connection`): \[`ConnectionItems`\<`NonNullable`\<`C`\>\>, `LoadMoreFn` \| `null`, `LoadMoreFn` \| `null`\]
|
|
4
|
+
|
|
5
|
+
Defined in: [packages/react-fate/src/useLiveListView.tsx:16](https://github.com/nkzw-tech/fate/blob/17081c4f677e224e55b75d9a31bd6e0a7ee94af1/packages/react-fate/src/useLiveListView.tsx#L16)
|
|
6
|
+
|
|
7
|
+
Subscribes to a connection field, returning live-updating items and pagination
|
|
8
|
+
helpers to load the next or previous page.
|
|
9
|
+
|
|
10
|
+
## Type Parameters
|
|
11
|
+
|
|
12
|
+
### C
|
|
13
|
+
|
|
14
|
+
`C` *extends* \{ `items?`: readonly `any`[]; `pagination?`: `Pagination`; \} \| `null` \| `undefined`
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
### selection
|
|
19
|
+
|
|
20
|
+
`ConnectionSelection`
|
|
21
|
+
|
|
22
|
+
### connection
|
|
23
|
+
|
|
24
|
+
`C`
|
|
25
|
+
|
|
26
|
+
## Returns
|
|
27
|
+
|
|
28
|
+
\[`ConnectionItems`\<`NonNullable`\<`C`\>\>, `LoadMoreFn` \| `null`, `LoadMoreFn` \| `null`\]
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Function: useLiveView()
|
|
2
|
+
|
|
3
|
+
> **useLiveView**\<`V`, `R`\>(`view`, `ref`): `R` *extends* `null` ? `null` : `Readonly`\<`ViewSelection`\<`V`\> *extends* `Selection`\<`ViewEntityWithTypename`\<`V`\>\> ? `Mask`\<`ViewEntityWithTypename`\<`V`\>, \{ \[K in string \| number \| symbol as K extends "\_\_typename" ? never : K\]?: SelectionFieldValue\<ViewEntityWithTypename\<V\>, K\> \} & `object` & `SelectionViewSpread`\<`ViewEntityWithTypename`\<`V`\>\> & `ViewSelection`\<`V`\>\> : `ViewEntityWithTypename`\<`V`\> & `object`\>
|
|
4
|
+
|
|
5
|
+
Defined in: [packages/react-fate/src/useLiveView.tsx:17](https://github.com/nkzw-tech/fate/blob/17081c4f677e224e55b75d9a31bd6e0a7ee94af1/packages/react-fate/src/useLiveView.tsx#L17)
|
|
6
|
+
|
|
7
|
+
Resolves a reference against a view and subscribes to live server updates for
|
|
8
|
+
that selection.
|
|
9
|
+
|
|
10
|
+
## Type Parameters
|
|
11
|
+
|
|
12
|
+
### V
|
|
13
|
+
|
|
14
|
+
`V` *extends* `View`\<`any`, `any`\>
|
|
15
|
+
|
|
16
|
+
### R
|
|
17
|
+
|
|
18
|
+
`R` *extends* `Readonly`\<\{ `__typename`: `ViewEntityName`; `[ViewsTag]`: `Set`\<`string`\>; `id`: `string` \| `number`; \}\> \| `null`
|
|
19
|
+
|
|
20
|
+
## Parameters
|
|
21
|
+
|
|
22
|
+
### view
|
|
23
|
+
|
|
24
|
+
`V`
|
|
25
|
+
|
|
26
|
+
### ref
|
|
27
|
+
|
|
28
|
+
`R`
|
|
29
|
+
|
|
30
|
+
## Returns
|
|
31
|
+
|
|
32
|
+
`R` *extends* `null` ? `null` : `Readonly`\<`ViewSelection`\<`V`\> *extends* `Selection`\<`ViewEntityWithTypename`\<`V`\>\> ? `Mask`\<`ViewEntityWithTypename`\<`V`\>, \{ \[K in string \| number \| symbol as K extends "\_\_typename" ? never : K\]?: SelectionFieldValue\<ViewEntityWithTypename\<V\>, K\> \} & `object` & `SelectionViewSpread`\<`ViewEntityWithTypename`\<`V`\>\> & `ViewSelection`\<`V`\>\> : `ViewEntityWithTypename`\<`V`\> & `object`\>
|
|
33
|
+
|
|
34
|
+
## Example
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
const post = useLiveView(PostView, postRef);
|
|
38
|
+
```
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Function: useRequest()
|
|
2
|
+
|
|
3
|
+
> **useRequest**\<`R`, `O`\>(`request`, `options?`): `RequestResult`\<`O`, `R`\>
|
|
4
|
+
|
|
5
|
+
Defined in: [packages/react-fate/src/useRequest.tsx:25](https://github.com/nkzw-tech/fate/blob/17081c4f677e224e55b75d9a31bd6e0a7ee94af1/packages/react-fate/src/useRequest.tsx#L25)
|
|
6
|
+
|
|
7
|
+
Declares the data a screen needs and kicks off fetching, suspending while the
|
|
8
|
+
request resolves.
|
|
9
|
+
|
|
10
|
+
## Type Parameters
|
|
11
|
+
|
|
12
|
+
### R
|
|
13
|
+
|
|
14
|
+
`R` *extends* `Request$1`
|
|
15
|
+
|
|
16
|
+
### O
|
|
17
|
+
|
|
18
|
+
`O` *extends* `FateRoots` = \{ `categories`: `RootDefinition`\<`"Category"`, `ConnectionResult`\<\{\[`key`: `string`\]: `any`; \}\>\>; `category`: `RootDefinition`\<`"Category"`, `Category`[]\>; `comment`: `RootDefinition`\<`"Comment"`, `Comment`[]\>; `commentSearch`: `RootDefinition`\<`"Comment"`, `ConnectionResult`\<\{\[`key`: `string`\]: `any`; \}\> & `ConnectionResult`\<`AnyRecord`\>\>; `event`: `RootDefinition`\<`"Event"`, `Event`[]\>; `eventAttendee`: `RootDefinition`\<`"EventAttendee"`, `EventAttendee`[]\>; `events`: `RootDefinition`\<`"Event"`, `ConnectionResult`\<\{\[`key`: `string`\]: `any`; \}\>\>; `post`: `RootDefinition`\<`"Post"`, `Post`[]\>; `posts`: `RootDefinition`\<`"Post"`, `ConnectionResult`\<\{\[`key`: `string`\]: `any`; \}\>\>; `tag`: `RootDefinition`\<`"Tag"`, `Tag`[]\>; `user`: `RootDefinition`\<`"User"`, `User`[]\>; `viewer`: `RootDefinition`\<`"User"`, `object` & `AnyRecord` \| `null`\>; \}
|
|
19
|
+
|
|
20
|
+
## Parameters
|
|
21
|
+
|
|
22
|
+
### request
|
|
23
|
+
|
|
24
|
+
`R`
|
|
25
|
+
|
|
26
|
+
### options?
|
|
27
|
+
|
|
28
|
+
`Readonly`\<\{ `mode?`: `RequestMode`; \}\>
|
|
29
|
+
|
|
30
|
+
## Returns
|
|
31
|
+
|
|
32
|
+
`RequestResult`\<`O`, `R`\>
|
|
33
|
+
|
|
34
|
+
## Example
|
|
35
|
+
|
|
36
|
+
```ts
|
|
37
|
+
const { posts } = useRequest({ posts: { list: PostView } });
|
|
38
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# Function: useView()
|
|
2
|
+
|
|
3
|
+
> **useView**\<`V`, `R`\>(`view`, `ref`): `R` *extends* `null` ? `null` : `Readonly`\<`ViewSelection`\<`V`\> *extends* `Selection`\<`ViewEntityWithTypename`\<`V`\>\> ? `Mask`\<`ViewEntityWithTypename`\<`V`\>, \{ \[K in string \| number \| symbol as K extends "\_\_typename" ? never : K\]?: SelectionFieldValue\<ViewEntityWithTypename\<V\>, K\> \} & `object` & `SelectionViewSpread`\<`ViewEntityWithTypename`\<`V`\>\> & `ViewSelection`\<`V`\>\> : `ViewEntityWithTypename`\<`V`\> & `object`\>
|
|
4
|
+
|
|
5
|
+
Defined in: [packages/react-fate/src/useView.tsx:37](https://github.com/nkzw-tech/fate/blob/17081c4f677e224e55b75d9a31bd6e0a7ee94af1/packages/react-fate/src/useView.tsx#L37)
|
|
6
|
+
|
|
7
|
+
Resolves a reference against a view and subscribes to updates for that selection.
|
|
8
|
+
|
|
9
|
+
## Type Parameters
|
|
10
|
+
|
|
11
|
+
### V
|
|
12
|
+
|
|
13
|
+
`V` *extends* `View`\<`any`, `any`\>
|
|
14
|
+
|
|
15
|
+
### R
|
|
16
|
+
|
|
17
|
+
`R` *extends* `Readonly`\<\{ `__typename`: `ViewEntityName`; `[ViewsTag]`: `Set`\<`string`\>; `id`: `string` \| `number`; \}\> \| `null`
|
|
18
|
+
|
|
19
|
+
## Parameters
|
|
20
|
+
|
|
21
|
+
### view
|
|
22
|
+
|
|
23
|
+
`V`
|
|
24
|
+
|
|
25
|
+
### ref
|
|
26
|
+
|
|
27
|
+
`R`
|
|
28
|
+
|
|
29
|
+
## Returns
|
|
30
|
+
|
|
31
|
+
`R` *extends* `null` ? `null` : `Readonly`\<`ViewSelection`\<`V`\> *extends* `Selection`\<`ViewEntityWithTypename`\<`V`\>\> ? `Mask`\<`ViewEntityWithTypename`\<`V`\>, \{ \[K in string \| number \| symbol as K extends "\_\_typename" ? never : K\]?: SelectionFieldValue\<ViewEntityWithTypename\<V\>, K\> \} & `object` & `SelectionViewSpread`\<`ViewEntityWithTypename`\<`V`\>\> & `ViewSelection`\<`V`\>\> : `ViewEntityWithTypename`\<`V`\> & `object`\>
|
|
32
|
+
|
|
33
|
+
## Example
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
const post = useView(PostView, postRef);
|
|
37
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Function: view()
|
|
2
|
+
|
|
3
|
+
> **view**\<`T`\>(): \<`S`\>(`select`) => `View`\<`T`, `S`\>
|
|
4
|
+
|
|
5
|
+
Defined in: packages/fate/lib/index.d.mts:88
|
|
6
|
+
|
|
7
|
+
Creates a reusable view for an object using the declared selection.
|
|
8
|
+
|
|
9
|
+
## Type Parameters
|
|
10
|
+
|
|
11
|
+
### T
|
|
12
|
+
|
|
13
|
+
`T` *extends* `Entity`
|
|
14
|
+
|
|
15
|
+
## Returns
|
|
16
|
+
|
|
17
|
+
\<`S`\>(`select`) => `View`\<`T`, `S`\>
|
|
18
|
+
|
|
19
|
+
## Example
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
const PostView = view<Post>()({
|
|
23
|
+
id: true,
|
|
24
|
+
title: true,
|
|
25
|
+
});
|
|
26
|
+
```
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# react-fate
|
|
2
|
+
|
|
3
|
+
The react fate library.
|
|
4
|
+
|
|
5
|
+
## Example
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { useView, view } from 'react-fate';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Type Aliases
|
|
12
|
+
|
|
13
|
+
- [ConnectionRef](type-aliases/ConnectionRef.md)
|
|
14
|
+
- [InferFateAPI](type-aliases/InferFateAPI.md)
|
|
15
|
+
- [ViewRef](type-aliases/ViewRef.md)
|
|
16
|
+
|
|
17
|
+
## Variables
|
|
18
|
+
|
|
19
|
+
- [toEntityId](variables/toEntityId.md)
|
|
20
|
+
|
|
21
|
+
## Functions
|
|
22
|
+
|
|
23
|
+
- [clientRoot](functions/clientRoot.md)
|
|
24
|
+
- [createClient](functions/createClient.md)
|
|
25
|
+
- [createHTTPTransport](functions/createHTTPTransport.md)
|
|
26
|
+
- [createTRPCTransport](functions/createTRPCTransport.md)
|
|
27
|
+
- [FateClient](functions/FateClient.md)
|
|
28
|
+
- [mutation](functions/mutation.md)
|
|
29
|
+
- [useFateClient](functions/useFateClient.md)
|
|
30
|
+
- [useListView](functions/useListView.md)
|
|
31
|
+
- [useLiveListView](functions/useLiveListView.md)
|
|
32
|
+
- [useLiveView](functions/useLiveView.md)
|
|
33
|
+
- [useRequest](functions/useRequest.md)
|
|
34
|
+
- [useView](functions/useView.md)
|
|
35
|
+
- [view](functions/view.md)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Type Alias: ConnectionRef\<TName\>
|
|
2
|
+
|
|
3
|
+
> **ConnectionRef**\<`TName`\> = `Readonly`\<\{ `items`: `ReadonlyArray`\<\{ `cursor?`: `string`; `node`: [`ViewRef`](ViewRef.md)\<`TName`\>; \}\>; `pagination?`: `Pagination`; \}\>
|
|
4
|
+
|
|
5
|
+
Defined in: packages/fate/lib/types-Dz46PXr3.d.mts:1132
|
|
6
|
+
|
|
7
|
+
Ref for a connection, including pagination metadata.
|
|
8
|
+
|
|
9
|
+
## Type Parameters
|
|
10
|
+
|
|
11
|
+
### TName
|
|
12
|
+
|
|
13
|
+
`TName` *extends* `string`
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Type Alias: ViewRef\<TName\>
|
|
2
|
+
|
|
3
|
+
> **ViewRef**\<`TName`\> = `Readonly`\<\{ `__typename`: `TName`; `[ViewsTag]`: `Set`\<`string`\>; `id`: `string` \| `number`; \}\>
|
|
4
|
+
|
|
5
|
+
Defined in: packages/fate/lib/types-Dz46PXr3.d.mts:1107
|
|
6
|
+
|
|
7
|
+
Reference to a normalized entity instance that can be resolved against one or more view tags.
|
|
8
|
+
|
|
9
|
+
## Type Parameters
|
|
10
|
+
|
|
11
|
+
### TName
|
|
12
|
+
|
|
13
|
+
`TName` *extends* `string`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Variable: toEntityId
|
|
2
|
+
|
|
3
|
+
> `const` **toEntityId**: (`type`, `rawId`) => `EntityId`
|
|
4
|
+
|
|
5
|
+
Defined in: packages/fate/lib/index.d.mts:75
|
|
6
|
+
|
|
7
|
+
Builds the canonical cache ID for an entity.
|
|
8
|
+
|
|
9
|
+
## Parameters
|
|
10
|
+
|
|
11
|
+
### type
|
|
12
|
+
|
|
13
|
+
`TypeName`
|
|
14
|
+
|
|
15
|
+
### rawId
|
|
16
|
+
|
|
17
|
+
`string` \| `number`
|
|
18
|
+
|
|
19
|
+
## Returns
|
|
20
|
+
|
|
21
|
+
`EntityId`
|