react-fate 1.5.1 → 1.6.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 +51 -155
- package/docs/api/functions/FateClient.md +1 -1
- package/docs/api/functions/clientRoot.md +1 -1
- package/docs/api/functions/createClient.md +1 -1
- package/docs/api/functions/createGraphQLTransport.md +1 -1
- package/docs/api/functions/createHTTPTransport.md +1 -1
- package/docs/api/functions/createTRPCTransport.md +1 -1
- package/docs/api/functions/defer.md +1 -1
- package/docs/api/functions/graphqlMutation.md +1 -1
- package/docs/api/functions/mutation.md +1 -1
- package/docs/api/functions/useFateClient.md +2 -2
- package/docs/api/functions/useListView.md +1 -1
- package/docs/api/functions/useLiveListView.md +1 -1
- package/docs/api/functions/useLiveView.md +2 -2
- package/docs/api/functions/useRequest.md +2 -2
- package/docs/api/functions/useView.md +3 -3
- package/docs/api/functions/view.md +1 -1
- package/docs/api/interfaces/Persistence.md +1 -1
- package/docs/api/interfaces/PersistenceSession.md +9 -9
- package/docs/api/type-aliases/ConnectionRef.md +1 -1
- package/docs/api/type-aliases/Deferred.md +1 -1
- package/docs/api/type-aliases/FateDehydratedState.md +1 -1
- package/docs/api/type-aliases/GraphQLMutationDefinition.md +1 -1
- package/docs/api/type-aliases/GraphQLMutationInput.md +1 -1
- package/docs/api/type-aliases/GraphQLMutationMap.md +1 -1
- package/docs/api/type-aliases/GraphQLMutationOutput.md +1 -1
- package/docs/api/type-aliases/GraphQLTransportOptions.md +12 -12
- package/docs/api/type-aliases/HydrateOptions.md +1 -1
- package/docs/api/type-aliases/HydrationLimits.md +1 -1
- package/docs/api/type-aliases/InferFateAPI.md +1 -1
- package/docs/api/type-aliases/Pagination.md +5 -5
- package/docs/api/type-aliases/PersistenceSnapshot.md +1 -1
- package/docs/api/type-aliases/ViewRef.md +1 -1
- package/docs/api/variables/toEntityId.md +1 -1
- package/docs/integrations/cloudflare.md +21 -139
- package/docs/integrations/void.md +33 -19
- package/lib/client.d.mts +3 -3
- package/lib/index.d.mts +11 -11
- package/lib/vite.d.mts +3 -4
- package/package.json +6 -6
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **GraphQLMutationOutput**\<`Definition`\> = `Definition` *extends* [`GraphQLMutationDefinition`](GraphQLMutationDefinition.md)\<`any`, `any`, infer Output\> ? `Output` : `never`
|
|
4
4
|
|
|
5
|
-
Defined in:
|
|
5
|
+
Defined in: fate/lib/graphqlTransport-D7IPm9wQ.d.mts:29
|
|
6
6
|
|
|
7
7
|
## Type Parameters
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **GraphQLTransportOptions**\<`Mutations`\> = `object`
|
|
4
4
|
|
|
5
|
-
Defined in:
|
|
5
|
+
Defined in: fate/lib/graphqlTransport-D7IPm9wQ.d.mts:45
|
|
6
6
|
|
|
7
7
|
## Type Parameters
|
|
8
8
|
|
|
@@ -16,7 +16,7 @@ Defined in: packages/fate/lib/graphqlTransport-CGYE4NdD.d.mts:45
|
|
|
16
16
|
|
|
17
17
|
> `optional` **decodeNodeId?**: (`type`, `id`) => `string` \| `number`
|
|
18
18
|
|
|
19
|
-
Defined in:
|
|
19
|
+
Defined in: fate/lib/graphqlTransport-D7IPm9wQ.d.mts:46
|
|
20
20
|
|
|
21
21
|
#### Parameters
|
|
22
22
|
|
|
@@ -38,7 +38,7 @@ Defined in: packages/fate/lib/graphqlTransport-CGYE4NdD.d.mts:46
|
|
|
38
38
|
|
|
39
39
|
> `optional` **encodeNodeId?**: (`type`, `id`) => `string` \| `number`
|
|
40
40
|
|
|
41
|
-
Defined in:
|
|
41
|
+
Defined in: fate/lib/graphqlTransport-D7IPm9wQ.d.mts:47
|
|
42
42
|
|
|
43
43
|
#### Parameters
|
|
44
44
|
|
|
@@ -60,7 +60,7 @@ Defined in: packages/fate/lib/graphqlTransport-CGYE4NdD.d.mts:47
|
|
|
60
60
|
|
|
61
61
|
> `optional` **eventSource?**: `EventSourceConstructor`
|
|
62
62
|
|
|
63
|
-
Defined in:
|
|
63
|
+
Defined in: fate/lib/graphqlTransport-D7IPm9wQ.d.mts:48
|
|
64
64
|
|
|
65
65
|
***
|
|
66
66
|
|
|
@@ -68,7 +68,7 @@ Defined in: packages/fate/lib/graphqlTransport-CGYE4NdD.d.mts:48
|
|
|
68
68
|
|
|
69
69
|
> `optional` **fetch?**: `FetchLike`
|
|
70
70
|
|
|
71
|
-
Defined in:
|
|
71
|
+
Defined in: fate/lib/graphqlTransport-D7IPm9wQ.d.mts:49
|
|
72
72
|
|
|
73
73
|
***
|
|
74
74
|
|
|
@@ -76,7 +76,7 @@ Defined in: packages/fate/lib/graphqlTransport-CGYE4NdD.d.mts:49
|
|
|
76
76
|
|
|
77
77
|
> `optional` **headers?**: `HeadersFactory`
|
|
78
78
|
|
|
79
|
-
Defined in:
|
|
79
|
+
Defined in: fate/lib/graphqlTransport-D7IPm9wQ.d.mts:50
|
|
80
80
|
|
|
81
81
|
***
|
|
82
82
|
|
|
@@ -84,7 +84,7 @@ Defined in: packages/fate/lib/graphqlTransport-CGYE4NdD.d.mts:50
|
|
|
84
84
|
|
|
85
85
|
> `optional` **live?**: `boolean` \| `GraphQLLiveOptions`
|
|
86
86
|
|
|
87
|
-
Defined in:
|
|
87
|
+
Defined in: fate/lib/graphqlTransport-D7IPm9wQ.d.mts:51
|
|
88
88
|
|
|
89
89
|
***
|
|
90
90
|
|
|
@@ -92,7 +92,7 @@ Defined in: packages/fate/lib/graphqlTransport-CGYE4NdD.d.mts:51
|
|
|
92
92
|
|
|
93
93
|
> `optional` **mutateDurably?**: `Transport`\<`Mutations`\>\[`"mutateDurably"`\]
|
|
94
94
|
|
|
95
|
-
Defined in:
|
|
95
|
+
Defined in: fate/lib/graphqlTransport-D7IPm9wQ.d.mts:52
|
|
96
96
|
|
|
97
97
|
***
|
|
98
98
|
|
|
@@ -100,7 +100,7 @@ Defined in: packages/fate/lib/graphqlTransport-CGYE4NdD.d.mts:52
|
|
|
100
100
|
|
|
101
101
|
> `optional` **mutations?**: `Record`\<`Extract`\<keyof `Mutations`, `string`\>, `GraphQLMutationRuntimeConfig`\>
|
|
102
102
|
|
|
103
|
-
Defined in:
|
|
103
|
+
Defined in: fate/lib/graphqlTransport-D7IPm9wQ.d.mts:53
|
|
104
104
|
|
|
105
105
|
***
|
|
106
106
|
|
|
@@ -108,7 +108,7 @@ Defined in: packages/fate/lib/graphqlTransport-CGYE4NdD.d.mts:53
|
|
|
108
108
|
|
|
109
109
|
> `optional` **roots?**: `Record`\<`string`, `GraphQLRootConfig`\>
|
|
110
110
|
|
|
111
|
-
Defined in:
|
|
111
|
+
Defined in: fate/lib/graphqlTransport-D7IPm9wQ.d.mts:54
|
|
112
112
|
|
|
113
113
|
***
|
|
114
114
|
|
|
@@ -116,7 +116,7 @@ Defined in: packages/fate/lib/graphqlTransport-CGYE4NdD.d.mts:54
|
|
|
116
116
|
|
|
117
117
|
> **types**: `ReadonlyArray`\<`Omit`\<`TypeConfig`, `"getId"`\> & `Partial`\<`Pick`\<`TypeConfig`, `"getId"`\>\>\>
|
|
118
118
|
|
|
119
|
-
Defined in:
|
|
119
|
+
Defined in: fate/lib/graphqlTransport-D7IPm9wQ.d.mts:55
|
|
120
120
|
|
|
121
121
|
***
|
|
122
122
|
|
|
@@ -124,4 +124,4 @@ Defined in: packages/fate/lib/graphqlTransport-CGYE4NdD.d.mts:55
|
|
|
124
124
|
|
|
125
125
|
> **url**: `string` \| `URL`
|
|
126
126
|
|
|
127
|
-
Defined in:
|
|
127
|
+
Defined in: fate/lib/graphqlTransport-D7IPm9wQ.d.mts:56
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
> **HydrateOptions** = `Readonly`\<\{ `merge?`: `"preserve-existing"` \| `"replace"`; \}\>
|
|
4
4
|
|
|
5
|
-
Defined in:
|
|
5
|
+
Defined in: fate/lib/transport-c5vvbtDC.d.mts:1181
|
|
6
6
|
|
|
7
7
|
Controls how `FateClient.hydrate()` reconciles a snapshot with browser cache state.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
> **HydrationLimits** = `Readonly`\<\{ `maxCollectionLength`: `number`; `maxNodes`: `number`; `maxStringLength`: `number`; \}\>
|
|
4
4
|
|
|
5
|
-
Defined in:
|
|
5
|
+
Defined in: fate/lib/transport-c5vvbtDC.d.mts:1191
|
|
6
6
|
|
|
7
7
|
Resource limits applied while encoding and decoding hydration snapshots.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **Pagination** = `object`
|
|
4
4
|
|
|
5
|
-
Defined in:
|
|
5
|
+
Defined in: fate/lib/transport-c5vvbtDC.d.mts:736
|
|
6
6
|
|
|
7
7
|
Pagination state returned alongside connection lists.
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ Pagination state returned alongside connection lists.
|
|
|
12
12
|
|
|
13
13
|
> **hasNext**: `boolean`
|
|
14
14
|
|
|
15
|
-
Defined in:
|
|
15
|
+
Defined in: fate/lib/transport-c5vvbtDC.d.mts:737
|
|
16
16
|
|
|
17
17
|
***
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ Defined in: packages/fate/lib/transport-DR0fwleU.d.mts:737
|
|
|
20
20
|
|
|
21
21
|
> **hasPrevious**: `boolean`
|
|
22
22
|
|
|
23
|
-
Defined in:
|
|
23
|
+
Defined in: fate/lib/transport-c5vvbtDC.d.mts:738
|
|
24
24
|
|
|
25
25
|
***
|
|
26
26
|
|
|
@@ -28,7 +28,7 @@ Defined in: packages/fate/lib/transport-DR0fwleU.d.mts:738
|
|
|
28
28
|
|
|
29
29
|
> `optional` **nextCursor?**: `string`
|
|
30
30
|
|
|
31
|
-
Defined in:
|
|
31
|
+
Defined in: fate/lib/transport-c5vvbtDC.d.mts:739
|
|
32
32
|
|
|
33
33
|
***
|
|
34
34
|
|
|
@@ -36,4 +36,4 @@ Defined in: packages/fate/lib/transport-DR0fwleU.d.mts:739
|
|
|
36
36
|
|
|
37
37
|
> `optional` **previousCursor?**: `string`
|
|
38
38
|
|
|
39
|
-
Defined in:
|
|
39
|
+
Defined in: fate/lib/transport-c5vvbtDC.d.mts:740
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
|
|
3
3
|
> **PersistenceSnapshot** = `Readonly`\<\{ `error?`: `Error`; `mutations`: `ReadonlyArray`\<`PersistedMutationStatus`\>; `status`: `"restoring"` \| `"ready"` \| `"error"` \| `"disposed"`; \}\>
|
|
4
4
|
|
|
5
|
-
Defined in:
|
|
5
|
+
Defined in: fate/lib/transport-c5vvbtDC.d.mts:1479
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **ViewRef**\<`TName`\> = `Readonly`\<\{ `__typename`: `TName`; `[ViewsTag]`: `Set`\<`string`\>; `id`: `string` \| `number`; \}\>
|
|
4
4
|
|
|
5
|
-
Defined in:
|
|
5
|
+
Defined in: fate/lib/transport-c5vvbtDC.d.mts:712
|
|
6
6
|
|
|
7
7
|
Reference to a normalized entity instance that can be resolved against one or more view tags.
|
|
8
8
|
|
|
@@ -1,161 +1,43 @@
|
|
|
1
1
|
# Cloudflare Integration
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Use it when your backend runs directly on Cloudflare Workers and you want fate live views without adopting the Void platform.
|
|
3
|
+
Deploy fate directly to your own Cloudflare account with [Void](void.md). The Void template includes the app, D1 database, Drizzle migrations, Better Auth, and live updates through `void-fate` and `void/live`.
|
|
6
4
|
|
|
7
5
|
## New Project
|
|
8
6
|
|
|
9
|
-
For a new Cloudflare Workers app, start from the Cloudflare template. It includes the client, Worker server, D1 migrations, Wrangler config, Durable Object live transport, auth wiring, and generated fate client setup.
|
|
10
|
-
|
|
11
7
|
```sh
|
|
12
|
-
vp create fate my-app --template
|
|
8
|
+
vp create fate my-app --template void
|
|
9
|
+
cd my-app
|
|
10
|
+
vp run dev:setup
|
|
11
|
+
vp run dev
|
|
13
12
|
```
|
|
14
13
|
|
|
15
|
-
|
|
14
|
+
Add `--framework vue` to the create command to use Vue instead of React.
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
vp create fate my-app --template cloudflare --framework vue
|
|
19
|
-
```
|
|
16
|
+
## Deploy
|
|
20
17
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
For an existing Cloudflare Workers project, add the packages directly:
|
|
18
|
+
From the project root:
|
|
24
19
|
|
|
25
20
|
```sh
|
|
26
|
-
|
|
27
|
-
pnpm add -D wrangler
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
For Vue clients, replace `react-fate` with `vue-fate`.
|
|
31
|
-
|
|
32
|
-
## Server Setup
|
|
33
|
-
|
|
34
|
-
Create a Cloudflare live stream and pass its Fate live facade to `createFateServer`.
|
|
35
|
-
|
|
36
|
-
```ts
|
|
37
|
-
// src/fate/live.ts
|
|
38
|
-
import { defineCloudflareFateLiveStream } from 'cf-fate/server';
|
|
39
|
-
|
|
40
|
-
export const fateStream = defineCloudflareFateLiveStream({
|
|
41
|
-
allowAnonymousControl: true,
|
|
42
|
-
binding: 'FATE_LIVE',
|
|
43
|
-
id: 'fate',
|
|
44
|
-
});
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
```ts
|
|
48
|
-
// src/fate/server.ts
|
|
49
|
-
import { createFateServer } from '@nkzw/fate/server';
|
|
50
|
-
import { createCloudflareFateLive } from 'cf-fate/server';
|
|
51
|
-
|
|
52
|
-
export const fateLive = createCloudflareFateLive();
|
|
53
|
-
export const { live } = fateLive;
|
|
54
|
-
|
|
55
|
-
export const fateServer = createFateServer({
|
|
56
|
-
live,
|
|
57
|
-
// context,
|
|
58
|
-
// roots,
|
|
59
|
-
// sources,
|
|
60
|
-
});
|
|
21
|
+
vp exec void deploy --platform cloudflare
|
|
61
22
|
```
|
|
62
23
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
```ts
|
|
66
|
-
live.update('Post', postId, { changed: ['likes'] });
|
|
67
|
-
live.connection('Post.comments', { id: postId }).appendNode('Comment', commentId);
|
|
68
|
-
```
|
|
24
|
+
Void signs you into Cloudflare when needed, lets you select your account, provisions resources, applies checked-in database migrations, and deploys the app. It saves resource IDs in the root `wrangler.jsonc`; commit that updated config for subsequent deployments. A Void platform account is not required.
|
|
69
25
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
Expose one route for Fate RPC and one route for the SSE live stream.
|
|
73
|
-
|
|
74
|
-
```ts
|
|
75
|
-
import {
|
|
76
|
-
createCloudflareFateLiveDurableObject,
|
|
77
|
-
defineCloudflareFateLiveRoute,
|
|
78
|
-
defineCloudflareFateRoute,
|
|
79
|
-
} from 'cf-fate/server';
|
|
80
|
-
import { fateStream } from './fate/live';
|
|
81
|
-
import { fateLive, fateServer } from './fate/server';
|
|
82
|
-
|
|
83
|
-
const fateRoute = defineCloudflareFateRoute(fateServer, fateLive, { stream: fateStream });
|
|
84
|
-
const fateLiveRoute = defineCloudflareFateLiveRoute(fateStream);
|
|
85
|
-
|
|
86
|
-
export const FateLiveDurableObject = createCloudflareFateLiveDurableObject({
|
|
87
|
-
binding: 'FATE_LIVE',
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
export default {
|
|
91
|
-
fetch(request, env, ctx) {
|
|
92
|
-
const url = new URL(request.url);
|
|
93
|
-
if (url.pathname === '/fate') {
|
|
94
|
-
return fateRoute.fetch(request, env, ctx);
|
|
95
|
-
}
|
|
96
|
-
if (url.pathname === '/fate-live') {
|
|
97
|
-
return fateLiveRoute.fetch(request, env, ctx);
|
|
98
|
-
}
|
|
99
|
-
return new Response('Not Found', { status: 404 });
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
## Wrangler
|
|
105
|
-
|
|
106
|
-
Add a Durable Object binding and migration. `cf-fate` uses `node:async_hooks`, so the Worker must enable Node compatibility.
|
|
107
|
-
|
|
108
|
-
```jsonc
|
|
109
|
-
{
|
|
110
|
-
"compatibility_flags": ["nodejs_compat"],
|
|
111
|
-
"durable_objects": {
|
|
112
|
-
"bindings": [
|
|
113
|
-
{
|
|
114
|
-
"name": "FATE_LIVE",
|
|
115
|
-
"class_name": "FateLiveDurableObject",
|
|
116
|
-
},
|
|
117
|
-
],
|
|
118
|
-
},
|
|
119
|
-
"migrations": [
|
|
120
|
-
{
|
|
121
|
-
"tag": "fate-live-v1",
|
|
122
|
-
"new_sqlite_classes": ["FateLiveDurableObject"],
|
|
123
|
-
},
|
|
124
|
-
],
|
|
125
|
-
}
|
|
126
|
-
```
|
|
26
|
+
The template includes the `VOID_LIVE` Durable Object binding and its class migration. Keep them in `wrangler.jsonc` so live subscriptions can receive updates across requests. RPC requests use `/fate`, and live updates use `/fate-live`.
|
|
127
27
|
|
|
128
|
-
|
|
28
|
+
After changing your database schema or auth configuration, run `vp run db:generate`, review and commit the generated migrations, then deploy. The migrations must include the Better Auth schema used in production.
|
|
129
29
|
|
|
130
|
-
|
|
30
|
+
See [Void's Cloudflare deployment guide](https://void.cloud/integrations/cloudflare) for custom domains, secrets, and CI configuration.
|
|
131
31
|
|
|
132
|
-
|
|
133
|
-
import { fate } from 'react-fate/vite';
|
|
32
|
+
## Migrating from cf-fate
|
|
134
33
|
|
|
135
|
-
fate
|
|
136
|
-
module: './src/fate/server.ts',
|
|
137
|
-
transport: 'cloudflare',
|
|
138
|
-
});
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
Then point the generated client at the Worker endpoints:
|
|
142
|
-
|
|
143
|
-
```tsx
|
|
144
|
-
import { FateClient } from 'react-fate';
|
|
145
|
-
import { createFateClient } from 'react-fate/client';
|
|
146
|
-
|
|
147
|
-
const fate = createFateClient({
|
|
148
|
-
liveUrl: 'http://localhost:8787/fate-live',
|
|
149
|
-
url: 'http://localhost:8787/fate',
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
export function App({ children }) {
|
|
153
|
-
return <FateClient client={fate}>{children}</FateClient>;
|
|
154
|
-
}
|
|
155
|
-
```
|
|
34
|
+
Fate 1.6 replaces the standalone Cloudflare adapter and template with the Void integration. Use `--template void` for new projects and `transport: 'void'` in the fate Vite plugin.
|
|
156
35
|
|
|
157
|
-
|
|
36
|
+
For an existing app, move the Worker routes into Void's `routes/` directory and follow the [Void integration](void.md) for the complete setup:
|
|
158
37
|
|
|
159
|
-
|
|
38
|
+
- Define the live stream with `defineLiveStream` from `void/live`.
|
|
39
|
+
- Use `createVoidFateLive`, `defineVoidFateRoute`, and `defineVoidFateLiveRoute` from `void-fate/server`.
|
|
40
|
+
- Let the generated client use `void/live/client` for live connections.
|
|
41
|
+
- Remove the `cf-fate` dependency and the custom Worker entry point.
|
|
160
42
|
|
|
161
|
-
|
|
43
|
+
Deploy the Void app as a new Worker with its `VOID_LIVE` binding and class migration. The old `FATE_LIVE` Durable Object class and its active connections are not migrated. Preserve existing database IDs and migration history when reusing your database, and reconnect clients to the new app after deployment.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Void Integration
|
|
2
2
|
|
|
3
|
-
`void-fate` is the
|
|
3
|
+
`void-fate` is the [Void](https://void.cloud) adapter for fate. Deploy your app directly to your own Cloudflare account or to the Void platform with the same integration.
|
|
4
4
|
|
|
5
5
|
Use this integration when your app runs on Void and you want the example app's
|
|
6
6
|
setup without copying its adapter glue.
|
|
@@ -127,14 +127,29 @@ live.connection('Post.comments', { id: postId }).appendNode('Comment', commentId
|
|
|
127
127
|
|
|
128
128
|
## Routes
|
|
129
129
|
|
|
130
|
+
Define a live stream once in a server-only module:
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
// src/fate/live.ts
|
|
134
|
+
import { defineLiveStream } from 'void/live';
|
|
135
|
+
|
|
136
|
+
export const fateStream = defineLiveStream({
|
|
137
|
+
allowAnonymousControl: true,
|
|
138
|
+
id: 'fate',
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
130
142
|
Add one route for fate RPC requests:
|
|
131
143
|
|
|
132
144
|
```tsx
|
|
133
145
|
// routes/fate.ts
|
|
134
146
|
import { defineVoidFateRoute } from 'void-fate/server';
|
|
147
|
+
import { fateStream } from '../src/fate/live.ts';
|
|
135
148
|
import { fateLive, fateServer } from '../src/fate/server.ts';
|
|
136
149
|
|
|
137
|
-
export const { GET, POST } = defineVoidFateRoute(fateServer, fateLive
|
|
150
|
+
export const { GET, POST } = defineVoidFateRoute(fateServer, fateLive, {
|
|
151
|
+
stream: fateStream,
|
|
152
|
+
});
|
|
138
153
|
```
|
|
139
154
|
|
|
140
155
|
Add a second route for the live SSE transport:
|
|
@@ -142,9 +157,9 @@ Add a second route for the live SSE transport:
|
|
|
142
157
|
```tsx
|
|
143
158
|
// routes/fate-live.ts
|
|
144
159
|
import { defineVoidFateLiveRoute } from 'void-fate/server';
|
|
145
|
-
import {
|
|
160
|
+
import { fateStream } from '../src/fate/live.ts';
|
|
146
161
|
|
|
147
|
-
export const { GET, POST } = defineVoidFateLiveRoute(
|
|
162
|
+
export const { GET, POST } = defineVoidFateLiveRoute(fateStream);
|
|
148
163
|
```
|
|
149
164
|
|
|
150
165
|
The live route handles `GET /fate-live` SSE connections and `POST /fate-live`
|
|
@@ -210,13 +225,7 @@ present.
|
|
|
210
225
|
## Custom Paths
|
|
211
226
|
|
|
212
227
|
The default route pair is `/fate` and `/fate-live`. If your Void app uses
|
|
213
|
-
different paths,
|
|
214
|
-
|
|
215
|
-
```tsx
|
|
216
|
-
export const fateLive = createVoidFateLive({
|
|
217
|
-
livePath: '/custom-fate-live',
|
|
218
|
-
});
|
|
219
|
-
```
|
|
228
|
+
different paths, update your route filenames and configure the matching client paths.
|
|
220
229
|
|
|
221
230
|
::: code-group
|
|
222
231
|
|
|
@@ -252,14 +261,19 @@ or router configuration matches the paths you pass to the client.
|
|
|
252
261
|
|
|
253
262
|
## Live Transport
|
|
254
263
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
In local development, `void-fate` uses a development token for that internal
|
|
260
|
-
publish request. Outside local development, Void must provide `__VOID_PROXY_TOKEN`
|
|
261
|
-
in the route environment. If no internal publish token is available, the adapter
|
|
262
|
-
falls back to the in-memory live bus for the current request context.
|
|
264
|
+
`createVoidFateLive` publishes entity and connection events through the `void/live`
|
|
265
|
+
stream associated with the current request. Void manages the Durable Object
|
|
266
|
+
transport that distributes events to connected clients across requests.
|
|
263
267
|
|
|
264
268
|
The live transport is best-effort and does not replay missed events after a
|
|
265
269
|
client reconnects. This matches fate's default in-memory live event bus.
|
|
270
|
+
|
|
271
|
+
## Cloudflare Deployment
|
|
272
|
+
|
|
273
|
+
From your project root, run:
|
|
274
|
+
|
|
275
|
+
```sh
|
|
276
|
+
vp exec void deploy --platform cloudflare
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Void provisions resources and deploys directly to your Cloudflare account. See the [Cloudflare integration](cloudflare.md) for setup and migration instructions.
|
package/lib/client.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createFateClient } from "@nkzw/fate/client";
|
|
2
2
|
//#region src/client.d.ts
|
|
3
|
-
interface ClientMutations {}
|
|
4
|
-
interface ClientRoots {}
|
|
3
|
+
export interface ClientMutations {}
|
|
4
|
+
export interface ClientRoots {}
|
|
5
5
|
//#endregion
|
|
6
|
-
export {
|
|
6
|
+
export { createFateClient };
|
package/lib/index.d.mts
CHANGED
|
@@ -10,7 +10,7 @@ type Roots = [GeneratedFateClient$1] extends [never] ? FateRoots : GeneratedFate
|
|
|
10
10
|
* @example
|
|
11
11
|
* const { posts } = useRequest({ posts: { list: PostView } });
|
|
12
12
|
*/
|
|
13
|
-
declare function useRequest<R extends Request, O extends FateRoots = Roots>(request: R, options?: RequestOptions): RequestResult<O, R>;
|
|
13
|
+
export declare function useRequest<R extends Request, O extends FateRoots = Roots>(request: R, options?: RequestOptions): RequestResult<O, R>;
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/context.d.ts
|
|
16
16
|
type GeneratedFateClient = ReturnType<typeof import('react-fate/client').createFateClient>;
|
|
@@ -18,14 +18,14 @@ type Mutations = [GeneratedFateClient] extends [never] ? FateMutations : Generat
|
|
|
18
18
|
/**
|
|
19
19
|
* Provider component that supplies a configured `FateClient` to React hooks.
|
|
20
20
|
*/
|
|
21
|
-
declare function FateClient({ children, client }: {
|
|
21
|
+
export declare function FateClient({ children, client }: {
|
|
22
22
|
children: ReactNode;
|
|
23
23
|
client: FateClient$1<any, any>;
|
|
24
24
|
}): import("react").JSX.Element;
|
|
25
25
|
/**
|
|
26
26
|
* Returns the nearest `FateClient` from context.
|
|
27
27
|
*/
|
|
28
|
-
declare function useFateClient<T extends [Roots, Mutations] = [Roots, Mutations]>(): FateClient$1<T[0], T[1]>;
|
|
28
|
+
export declare function useFateClient<T extends [Roots, Mutations] = [Roots, Mutations]>(): FateClient$1<T[0], T[1]>;
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/useLiveView.d.ts
|
|
31
31
|
type ViewEntityWithTypename$1<V extends View<any, any>> = ViewEntity<V> & {
|
|
@@ -38,8 +38,8 @@ type ViewEntityWithTypename$1<V extends View<any, any>> = ViewEntity<V> & {
|
|
|
38
38
|
* @example
|
|
39
39
|
* const post = useLiveView(PostView, postRef);
|
|
40
40
|
*/
|
|
41
|
-
declare function useLiveView<V extends View<any, any>, R extends ViewRef$1<ViewEntityName<V>> | null>(view: V, ref: R): R extends null ? null : ViewData<ViewEntityWithTypename$1<V>, ViewSelection<V>>;
|
|
42
|
-
declare function useLiveView<V extends View<any, any>, R extends Deferred$1<ViewRef$1<ViewEntityName<V>>> | null>(view: V, ref: R): R extends null ? null : ViewData<ViewEntityWithTypename$1<V>, ViewSelection<V>>;
|
|
41
|
+
export declare function useLiveView<V extends View<any, any>, R extends ViewRef$1<ViewEntityName<V>> | null>(view: V, ref: R): R extends null ? null : ViewData<ViewEntityWithTypename$1<V>, ViewSelection<V>>;
|
|
42
|
+
export declare function useLiveView<V extends View<any, any>, R extends Deferred$1<ViewRef$1<ViewEntityName<V>>> | null>(view: V, ref: R): R extends null ? null : ViewData<ViewEntityWithTypename$1<V>, ViewSelection<V>>;
|
|
43
43
|
//#endregion
|
|
44
44
|
//#region src/listView.d.ts
|
|
45
45
|
type ConnectionItems<C> = C extends {
|
|
@@ -62,7 +62,7 @@ type ResolvedConnection$1<C> = C extends Deferred$1<infer Value> ? Value : NonNu
|
|
|
62
62
|
* Subscribes to a connection field, returning live-updating items and pagination
|
|
63
63
|
* helpers to load the next or previous page.
|
|
64
64
|
*/
|
|
65
|
-
declare function useLiveListView<C extends ConnectionValue$1 | Deferred$1<ConnectionValue$1> | null | undefined>(selection: ConnectionSelection, connection: C): [ConnectionItems<ResolvedConnection$1<C>>, LoadMoreFn | null, LoadMoreFn | null];
|
|
65
|
+
export declare function useLiveListView<C extends ConnectionValue$1 | Deferred$1<ConnectionValue$1> | null | undefined>(selection: ConnectionSelection, connection: C): [ConnectionItems<ResolvedConnection$1<C>>, LoadMoreFn | null, LoadMoreFn | null];
|
|
66
66
|
//#endregion
|
|
67
67
|
//#region src/useView.d.ts
|
|
68
68
|
type ViewEntityWithTypename<V extends View<any, any>> = ViewEntity<V> & {
|
|
@@ -74,9 +74,9 @@ type ViewEntityWithTypename<V extends View<any, any>> = ViewEntity<V> & {
|
|
|
74
74
|
* @example
|
|
75
75
|
* const post = useView(PostView, postRef);
|
|
76
76
|
*/
|
|
77
|
-
declare function useView<V extends View<any, any>, R extends ViewRef$1<ViewEntityName<V>> | null>(view: V, ref: R): R extends null ? null : ViewData<ViewEntityWithTypename<V>, ViewSelection<V>>;
|
|
78
|
-
declare function useView<V extends View<any, any>, R extends Deferred$1<ViewRef$1<ViewEntityName<V>>> | null>(view: V, ref: R): R extends null ? null : ViewData<ViewEntityWithTypename<V>, ViewSelection<V>>;
|
|
79
|
-
declare function useView<V extends View<any, any>>(view: V, ref: Deferred$1<ViewRef$1<ViewEntityName<V>>> | ViewRef$1<ViewEntityName<V>> | null): ViewData<ViewEntityWithTypename<V>, ViewSelection<V>> | null;
|
|
77
|
+
export declare function useView<V extends View<any, any>, R extends ViewRef$1<ViewEntityName<V>> | null>(view: V, ref: R): R extends null ? null : ViewData<ViewEntityWithTypename<V>, ViewSelection<V>>;
|
|
78
|
+
export declare function useView<V extends View<any, any>, R extends Deferred$1<ViewRef$1<ViewEntityName<V>>> | null>(view: V, ref: R): R extends null ? null : ViewData<ViewEntityWithTypename<V>, ViewSelection<V>>;
|
|
79
|
+
export declare function useView<V extends View<any, any>>(view: V, ref: Deferred$1<ViewRef$1<ViewEntityName<V>>> | ViewRef$1<ViewEntityName<V>> | null): ViewData<ViewEntityWithTypename<V>, ViewSelection<V>> | null;
|
|
80
80
|
//#endregion
|
|
81
81
|
//#region src/useListView.d.ts
|
|
82
82
|
type ConnectionValue = {
|
|
@@ -88,6 +88,6 @@ type ResolvedConnection<C> = C extends Deferred$1<infer Value> ? Value : NonNull
|
|
|
88
88
|
* Subscribes to a connection field, returning the current items and pagination
|
|
89
89
|
* helpers to load the next or previous page.
|
|
90
90
|
*/
|
|
91
|
-
declare function useListView<C extends ConnectionValue | Deferred$1<ConnectionValue> | null | undefined>(selection: ConnectionSelection, connection: C): [ConnectionItems<ResolvedConnection<C>>, LoadMoreFn | null, LoadMoreFn | null];
|
|
91
|
+
export declare function useListView<C extends ConnectionValue | Deferred$1<ConnectionValue> | null | undefined>(selection: ConnectionSelection, connection: C): [ConnectionItems<ResolvedConnection<C>>, LoadMoreFn | null, LoadMoreFn | null];
|
|
92
92
|
//#endregion
|
|
93
|
-
export { type ConnectionRef, type Deferred,
|
|
93
|
+
export { type ConnectionRef, type Deferred, type FateDehydratedState, type GraphQLMutationDefinition, type GraphQLMutationInput, type GraphQLMutationMap, type GraphQLMutationOutput, type GraphQLTransportOptions, type HydrateOptions, type HydrationLimits, type InferFateAPI, type Pagination, type Persistence, type PersistenceSession, type PersistenceSnapshot, type ViewRef, clientRoot, createClient, createGraphQLTransport, createHTTPTransport, createTRPCTransport, defer, graphqlMutation, mutation, toEntityId, view };
|
package/lib/vite.d.mts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { FateViteTransport, fate as fate$1 } from "@nkzw/fate/vite";
|
|
2
2
|
//#region src/vite.d.ts
|
|
3
|
-
type FateVitePluginOptions = {
|
|
3
|
+
export type FateVitePluginOptions = {
|
|
4
4
|
generatedFile?: false | string;
|
|
5
5
|
module: string;
|
|
6
6
|
transport?: FateViteTransport;
|
|
7
7
|
tsconfigFile?: false | string;
|
|
8
8
|
};
|
|
9
|
-
declare const fate: (options: FateVitePluginOptions) => ReturnType<typeof fate$1>;
|
|
10
|
-
//#endregion
|
|
11
|
-
export { FateVitePluginOptions, fate };
|
|
9
|
+
export declare const fate: (options: FateVitePluginOptions) => ReturnType<typeof fate$1>;
|
|
10
|
+
//#endregion
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-fate",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "fate is a modern data client for React.",
|
|
5
5
|
"homepage": "https://github.com/nkzw-tech/fate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,13 +40,13 @@
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@nkzw/fate": "
|
|
43
|
+
"@nkzw/fate": "1.6.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@types/react": "
|
|
47
|
-
"@types/react-dom": "
|
|
48
|
-
"react": "
|
|
49
|
-
"react-dom": "
|
|
46
|
+
"@types/react": "19.3.0",
|
|
47
|
+
"@types/react-dom": "19.3.0",
|
|
48
|
+
"react": "19.3.0",
|
|
49
|
+
"react-dom": "19.3.0"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"react": "^19.2.0",
|