@nkzw/fate 1.2.0 → 1.3.1
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 +179 -1
- package/docs/api/classes/FateClient.md +40 -40
- 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/getDeferredMetadata.md +1 -1
- package/docs/api/functions/getListEntries.md +1 -1
- package/docs/api/functions/getSelectionPlan.md +1 -1
- package/docs/api/functions/graphqlMutation.md +1 -1
- package/docs/api/functions/isDeferred.md +1 -1
- package/docs/api/functions/isRecord.md +1 -1
- package/docs/api/functions/isViewTag.md +1 -1
- package/docs/api/functions/liveConnectionTopic.md +1 -1
- package/docs/api/functions/liveEntityTopic.md +1 -1
- package/docs/api/functions/liveGlobalConnectionTopic.md +1 -1
- package/docs/api/functions/mutation.md +1 -1
- package/docs/api/functions/toEntityId.md +1 -1
- package/docs/api/functions/view.md +1 -1
- package/docs/api/interfaces/FateThenable.md +3 -3
- package/docs/api/interfaces/Transport.md +7 -7
- package/docs/api/server/classes/FateRequestError.md +5 -5
- package/docs/api/server/drizzle/functions/createDrizzleFate.md +1 -1
- package/docs/api/server/drizzle/functions/createDrizzleSourceAdapter.md +1 -1
- package/docs/api/server/drizzle/functions/createDrizzleSourceRegistry.md +1 -1
- package/docs/api/server/drizzle/type-aliases/DrizzleManyToManyConfig.md +1 -1
- package/docs/api/server/drizzle/type-aliases/DrizzleManyToManyInput.md +1 -1
- package/docs/api/server/drizzle/type-aliases/DrizzleQueryExtra.md +3 -3
- package/docs/api/server/drizzle/type-aliases/DrizzleSourceAdapter.md +9 -9
- package/docs/api/server/drizzle/type-aliases/DrizzleViewConfig.md +1 -1
- package/docs/api/server/functions/bindSourceProcedures.md +1 -1
- package/docs/api/server/functions/computed.md +1 -1
- package/docs/api/server/functions/count.md +1 -1
- package/docs/api/server/functions/createFateFetchHandler.md +1 -1
- package/docs/api/server/functions/createFateServer.md +1 -1
- package/docs/api/server/functions/createHonoFateHandler.md +1 -1
- package/docs/api/server/functions/createLiveEventBus.md +1 -1
- package/docs/api/server/functions/createNestedSourcePlan.md +1 -1
- package/docs/api/server/functions/createResolver.md +1 -1
- package/docs/api/server/functions/createSourcePlan.md +1 -1
- package/docs/api/server/functions/createSourceProcedures.md +1 -1
- package/docs/api/server/functions/dataView.md +1 -1
- package/docs/api/server/functions/field.md +1 -1
- package/docs/api/server/functions/getNestedSelection.md +1 -1
- package/docs/api/server/functions/getScopedArgs.md +1 -1
- package/docs/api/server/functions/hasNestedSelection.md +1 -1
- package/docs/api/server/functions/list.md +1 -1
- package/docs/api/server/functions/refetchSourceById.md +1 -1
- package/docs/api/server/functions/resolveSourceById.md +1 -1
- package/docs/api/server/functions/resolveSourceByIds.md +1 -1
- package/docs/api/server/functions/resolveSourceConnection.md +1 -1
- package/docs/api/server/functions/resolver.md +1 -1
- package/docs/api/server/functions/toPrismaSelect.md +1 -1
- package/docs/api/server/functions/withConnection.md +1 -1
- package/docs/api/server/prisma/functions/createPrismaFate.md +1 -1
- package/docs/api/server/prisma/functions/createPrismaSourceAdapter.md +1 -1
- package/docs/api/server/prisma/functions/createPrismaSourceRegistry.md +1 -1
- package/docs/api/server/prisma/functions/prismaConnectionArgs.md +1 -1
- package/docs/api/server/prisma/type-aliases/PrismaDelegate.md +4 -4
- package/docs/api/server/prisma/type-aliases/PrismaQueryExtra.md +1 -1
- package/docs/api/server/prisma/type-aliases/PrismaSourceAdapter.md +9 -9
- package/docs/api/server/prisma/type-aliases/PrismaViewConfig.md +1 -1
- package/docs/api/server/type-aliases/ComputedField.md +5 -5
- package/docs/api/server/type-aliases/ComputedSelection.md +1 -1
- package/docs/api/server/type-aliases/ConnectionItem.md +3 -3
- package/docs/api/server/type-aliases/ConnectionPagination.md +5 -5
- package/docs/api/server/type-aliases/ConnectionResult.md +3 -3
- package/docs/api/server/type-aliases/CountSelection.md +4 -4
- package/docs/api/server/type-aliases/CountWhere.md +1 -1
- package/docs/api/server/type-aliases/DataViewListOptions.md +2 -2
- package/docs/api/server/type-aliases/DataViewOrderBy.md +1 -1
- package/docs/api/server/type-aliases/DataViewOrderDirection.md +1 -1
- package/docs/api/server/type-aliases/DataViewResult.md +1 -1
- package/docs/api/server/type-aliases/Entity.md +1 -1
- package/docs/api/server/type-aliases/FateServer.md +5 -5
- package/docs/api/server/type-aliases/FateServerManifest.md +1 -1
- package/docs/api/server/type-aliases/FieldSelection.md +3 -3
- package/docs/api/server/type-aliases/LiveConnectionEventType.md +1 -1
- package/docs/api/server/type-aliases/LiveConnectionSourceEvent.md +1 -1
- package/docs/api/server/type-aliases/LiveEventBus.md +1 -1
- package/docs/api/server/type-aliases/LiveEventType.md +1 -1
- package/docs/api/server/type-aliases/LiveSourceEvent.md +1 -1
- package/docs/api/server/type-aliases/NativeFateAPI.md +4 -4
- package/docs/api/server/type-aliases/OrderDirection.md +1 -1
- package/docs/api/server/type-aliases/SourceConfig.md +6 -6
- package/docs/api/server/type-aliases/SourceDefinition.md +6 -6
- package/docs/api/server/type-aliases/SourceOrder.md +1 -1
- package/docs/api/server/type-aliases/SourceOrderField.md +3 -3
- package/docs/api/server/type-aliases/SourcePlan.md +1 -1
- package/docs/api/server/type-aliases/SourcePlanNode.md +1 -1
- package/docs/api/server/type-aliases/SourceRegistry.md +1 -1
- package/docs/api/server/type-aliases/SourceRelation.md +1 -1
- package/docs/api/server/type-aliases/SourceRelationConfig.md +1 -1
- package/docs/api/server/variables/byIdInput.md +1 -1
- package/docs/api/server/variables/connectionArgs.md +1 -1
- package/docs/api/type-aliases/ConnectionMetadata.md +1 -1
- package/docs/api/type-aliases/ConnectionRef.md +1 -1
- package/docs/api/type-aliases/Deferred.md +1 -1
- package/docs/api/type-aliases/DeferredMetadata.md +1 -1
- package/docs/api/type-aliases/DeferredSelection.md +1 -1
- package/docs/api/type-aliases/DeferredSnapshot.md +1 -1
- package/docs/api/type-aliases/Entity.md +2 -2
- package/docs/api/type-aliases/EntityId.md +1 -1
- package/docs/api/type-aliases/FateDehydratedState.md +1 -1
- package/docs/api/type-aliases/FateLiveConnectionEvent.md +1 -1
- package/docs/api/type-aliases/FateLiveEvent.md +1 -1
- package/docs/api/type-aliases/FateMutations.md +1 -1
- package/docs/api/type-aliases/FateOperation.md +1 -1
- package/docs/api/type-aliases/FateProtocolRequest.md +1 -1
- package/docs/api/type-aliases/FateProtocolResponse.md +1 -1
- package/docs/api/type-aliases/FateRecord.md +1 -1
- package/docs/api/type-aliases/FateRoots.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 +11 -11
- 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/List.md +1 -1
- package/docs/api/type-aliases/ListEntry.md +1 -1
- package/docs/api/type-aliases/ListItem.md +1 -1
- package/docs/api/type-aliases/Mask.md +1 -1
- package/docs/api/type-aliases/MutationDefinition.md +1 -1
- package/docs/api/type-aliases/MutationEntity.md +1 -1
- package/docs/api/type-aliases/MutationIdentifier.md +1 -1
- package/docs/api/type-aliases/MutationInput.md +1 -1
- package/docs/api/type-aliases/MutationResult.md +1 -1
- package/docs/api/type-aliases/NodesItem.md +1 -1
- package/docs/api/type-aliases/Pagination.md +5 -5
- package/docs/api/type-aliases/Request.md +1 -1
- package/docs/api/type-aliases/RequestMode.md +1 -1
- package/docs/api/type-aliases/RequestOptions.md +1 -1
- package/docs/api/type-aliases/RequestResult.md +1 -1
- package/docs/api/type-aliases/Selection.md +1 -1
- package/docs/api/type-aliases/Snapshot.md +1 -1
- package/docs/api/type-aliases/TypeConfig.md +4 -4
- package/docs/api/type-aliases/View.md +1 -1
- package/docs/api/type-aliases/ViewData.md +1 -1
- package/docs/api/type-aliases/ViewEntity.md +1 -1
- package/docs/api/type-aliases/ViewEntityName.md +1 -1
- package/docs/api/type-aliases/ViewRef.md +1 -1
- package/docs/api/type-aliases/ViewSelection.md +1 -1
- package/docs/api/type-aliases/ViewSnapshot.md +1 -1
- package/docs/api/type-aliases/ViewTag.md +1 -1
- package/docs/api/variables/ConnectionTag.md +1 -1
- package/docs/api/variables/DeferTag.md +1 -1
- package/docs/api/variables/DeferredTag.md +1 -1
- package/docs/integrations/cloudflare.md +161 -0
- package/docs/integrations/void.md +17 -1
- package/lib/vite.d.mts +1 -1
- package/lib/vite.mjs +27 -7
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **MutationInput**\<`M`\> = `M` *extends* `__MutationInputAnchor`\<infer I\> ? `I` : `never`
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:478](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:478](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L478)
|
|
6
6
|
|
|
7
7
|
Extracts the input type from a mutation definition or identifier.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **MutationResult**\<`M`\> = `M` *extends* `__MutationResultAnchor`\<infer R\> ? `R` : `never`
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:481](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:481](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L481)
|
|
6
6
|
|
|
7
7
|
Extracts the result type from a mutation definition or identifier.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **NodesItem**\<`V`\> = `Readonly`\<\{ `ids`: `ReadonlyArray`\<`string` \| `number`\>; `view`: `V`; \}\>
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:366](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:366](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L366)
|
|
6
6
|
|
|
7
7
|
Definition of a node request with explicit IDs for fetching data from the backend.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **Pagination** = `object`
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:131](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:131](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L131)
|
|
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: [packages/fate/src/types.ts:132](https://github.com/nkzw-tech/fate/blob/
|
|
15
|
+
Defined in: [packages/fate/src/types.ts:132](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L132)
|
|
16
16
|
|
|
17
17
|
***
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ Defined in: [packages/fate/src/types.ts:132](https://github.com/nkzw-tech/fate/b
|
|
|
20
20
|
|
|
21
21
|
> **hasPrevious**: `boolean`
|
|
22
22
|
|
|
23
|
-
Defined in: [packages/fate/src/types.ts:133](https://github.com/nkzw-tech/fate/blob/
|
|
23
|
+
Defined in: [packages/fate/src/types.ts:133](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L133)
|
|
24
24
|
|
|
25
25
|
***
|
|
26
26
|
|
|
@@ -28,7 +28,7 @@ Defined in: [packages/fate/src/types.ts:133](https://github.com/nkzw-tech/fate/b
|
|
|
28
28
|
|
|
29
29
|
> `optional` **nextCursor?**: `string`
|
|
30
30
|
|
|
31
|
-
Defined in: [packages/fate/src/types.ts:134](https://github.com/nkzw-tech/fate/blob/
|
|
31
|
+
Defined in: [packages/fate/src/types.ts:134](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L134)
|
|
32
32
|
|
|
33
33
|
***
|
|
34
34
|
|
|
@@ -36,4 +36,4 @@ Defined in: [packages/fate/src/types.ts:134](https://github.com/nkzw-tech/fate/b
|
|
|
36
36
|
|
|
37
37
|
> `optional` **previousCursor?**: `string`
|
|
38
38
|
|
|
39
|
-
Defined in: [packages/fate/src/types.ts:135](https://github.com/nkzw-tech/fate/blob/
|
|
39
|
+
Defined in: [packages/fate/src/types.ts:135](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L135)
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
> **Request** = `Record`\<`string`, `RequestItem`\>
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:378](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:378](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L378)
|
|
6
6
|
|
|
7
7
|
Collection of node and list requests describing the data a screen needs.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
> **RequestMode** = `"cache-first"` \| `"stale-while-revalidate"` \| `"network-only"`
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/client.ts:89](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/client.ts:89](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/client.ts#L89)
|
|
6
6
|
|
|
7
7
|
Strategy used when resolving a request.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
> **RequestOptions** = `Readonly`\<\{ `mode?`: [`RequestMode`](RequestMode.md); \}\>
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/client.ts:100](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/client.ts:100](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/client.ts#L100)
|
|
6
6
|
|
|
7
7
|
Request options that affect how requests are fetched and retained.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **RequestResult**\<`R`, `Q`\> = `{ [K in keyof Q]: K extends keyof R ? ListResult<Q[K], RootType<R[K]>, RootResult<R[K]>> : never }`
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:424](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:424](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L424)
|
|
6
6
|
|
|
7
7
|
The result of a `FateClient.request` and `useRequest` call, mapping each
|
|
8
8
|
request key to its corresponding result.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **Selection**\<`T`\> = `SelectionShape`\<`T`\> & `SelectionViewSpread`\<`T`\>
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:229](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:229](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L229)
|
|
6
6
|
|
|
7
7
|
Declarative selection of the fields a view needs from an entity.
|
|
8
8
|
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
> **Snapshot** = `Readonly`\<\{ `mask?`: `FieldMask`; `record?`: [`FateRecord`](FateRecord.md); \}\>
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:513](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:513](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L513)
|
|
6
6
|
|
|
7
7
|
Snapshot captured before mutating the cache, used to roll back on errors.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **TypeConfig** = `object`
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:124](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:124](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L124)
|
|
6
6
|
|
|
7
7
|
Configuration for a server entity type used by the client cache.
|
|
8
8
|
|
|
@@ -12,7 +12,7 @@ Configuration for a server entity type used by the client cache.
|
|
|
12
12
|
|
|
13
13
|
> `optional` **fields?**: `Record`\<`string`, `RelationDescriptor`\>
|
|
14
14
|
|
|
15
|
-
Defined in: [packages/fate/src/types.ts:125](https://github.com/nkzw-tech/fate/blob/
|
|
15
|
+
Defined in: [packages/fate/src/types.ts:125](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L125)
|
|
16
16
|
|
|
17
17
|
***
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ Defined in: [packages/fate/src/types.ts:125](https://github.com/nkzw-tech/fate/b
|
|
|
20
20
|
|
|
21
21
|
> **getId**: (`record`) => `string` \| `number`
|
|
22
22
|
|
|
23
|
-
Defined in: [packages/fate/src/types.ts:126](https://github.com/nkzw-tech/fate/blob/
|
|
23
|
+
Defined in: [packages/fate/src/types.ts:126](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L126)
|
|
24
24
|
|
|
25
25
|
#### Parameters
|
|
26
26
|
|
|
@@ -38,4 +38,4 @@ Defined in: [packages/fate/src/types.ts:126](https://github.com/nkzw-tech/fate/b
|
|
|
38
38
|
|
|
39
39
|
> **type**: `string`
|
|
40
40
|
|
|
41
|
-
Defined in: [packages/fate/src/types.ts:127](https://github.com/nkzw-tech/fate/blob/
|
|
41
|
+
Defined in: [packages/fate/src/types.ts:127](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L127)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **View**\<`T`, `S`\> = `Readonly`\<\{\[`viewTag`: `` `__fate-view__${string}` ``\]: `Readonly`\<\{ `[ViewKind]`: `true`; `select`: `S`; \}\>; \}\> & `__ViewEntityAnchor`\<`T`\> & `__ViewSelectionAnchor`\<`S`\>
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:245](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:245](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L245)
|
|
6
6
|
|
|
7
7
|
Definition of a view over an entity type, including the selection of fields.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **ViewData**\<`T`, `S`\> = `Readonly`\<`S` *extends* [`Selection`](Selection.md)\<`T`\> ? [`Mask`](Mask.md)\<`T`, `S`\> : `T` & `object`\>
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:261](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:261](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L261)
|
|
6
6
|
|
|
7
7
|
Data returned from a resolved view with masking applied and view tags
|
|
8
8
|
attached for downstream composition.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **ViewEntity**\<`V`\> = `V` *extends* [`View`](View.md)\<infer T, `any`\> ? `T` : `never`
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:335](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:335](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L335)
|
|
6
6
|
|
|
7
7
|
Entity type captured from a view definition.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **ViewEntityName**\<`V`\> = [`ViewEntity`](ViewEntity.md)\<`V`\>\[`"__typename"`\] & `string`
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:338](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:338](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L338)
|
|
6
6
|
|
|
7
7
|
Name of the entity type captured from a view definition.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **ViewRef**\<`TName`\> = `Readonly`\<\{ `__typename`: `TName`; `[ViewsTag]`: `Set`\<`string`\>; `id`: `string` \| `number`; \}\>
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:108](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:108](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L108)
|
|
6
6
|
|
|
7
7
|
Reference to a normalized entity instance that can be resolved against one or more view tags.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **ViewSelection**\<`V`\> = `V` *extends* `object` ? `S` : `never`
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:341](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:341](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L341)
|
|
6
6
|
|
|
7
7
|
Selection captured from a view definition.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **ViewSnapshot**\<`T`, `S`\> = `Readonly`\<\{ `coverage`: `ReadonlyArray`\<readonly \[[`EntityId`](EntityId.md), `ReadonlySet`\<`string`\>\]\>; `data`: [`ViewData`](ViewData.md)\<`T`, `S`\>; \}\>
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:271](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:271](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L271)
|
|
6
6
|
|
|
7
7
|
Snapshot returned by the cache for a view, including the masked data and all
|
|
8
8
|
referenced entity IDs.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
> **ViewTag** = `` `__fate-view__${string}` ``
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:56](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:56](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L56)
|
|
6
6
|
|
|
7
7
|
Unique key that identifies a view composition entry inside a selection or reference.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
> `const` **ConnectionTag**: *typeof* `ConnectionTag`
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:20](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:20](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L20)
|
|
6
6
|
|
|
7
7
|
Symbol attached to connection results so pagination helpers can find their metadata.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
> `const` **DeferTag**: *typeof* `DeferTag`
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:23](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:23](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L23)
|
|
6
6
|
|
|
7
7
|
Symbol used to mark a selection as deferred.
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
> `const` **DeferredTag**: *typeof* `DeferredTag`
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:26](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:26](https://github.com/nkzw-tech/fate/blob/bdff68417591ff0372c03c214bbc7c722cdf13a2/packages/fate/src/types.ts#L26)
|
|
6
6
|
|
|
7
7
|
Symbol attached to deferred values returned from masked views.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# Cloudflare Integration
|
|
2
|
+
|
|
3
|
+
`cf-fate` is the first-class Cloudflare Workers adapter for Fate native HTTP transport and live views.
|
|
4
|
+
|
|
5
|
+
Use it when your backend runs directly on Cloudflare Workers and you want fate live views without adopting the Void platform.
|
|
6
|
+
|
|
7
|
+
## New Project
|
|
8
|
+
|
|
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
|
+
```sh
|
|
12
|
+
vp create fate my-app --template cloudflare
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Use Vue instead of React with:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
vp create fate my-app --template cloudflare --framework vue
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Existing Project
|
|
22
|
+
|
|
23
|
+
For an existing Cloudflare Workers project, add the packages directly:
|
|
24
|
+
|
|
25
|
+
```sh
|
|
26
|
+
pnpm add @nkzw/fate react-fate cf-fate drizzle-orm
|
|
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
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Publish from mutations through the normal Fate live bus:
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
live.update('Post', postId, { changed: ['likes'] });
|
|
67
|
+
live.connection('Post.comments', { id: postId }).appendNode('Comment', commentId);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## Worker Routes
|
|
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
|
+
```
|
|
127
|
+
|
|
128
|
+
## Client
|
|
129
|
+
|
|
130
|
+
Use the Cloudflare transport in the Fate Vite plugin:
|
|
131
|
+
|
|
132
|
+
```ts
|
|
133
|
+
import { fate } from 'react-fate/vite';
|
|
134
|
+
|
|
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
|
+
```
|
|
156
|
+
|
|
157
|
+
## Semantics
|
|
158
|
+
|
|
159
|
+
`cf-fate` uses one browser `EventSource` per Fate client and multiplexes entity and connection topics over that stream. Durable Objects keep connection and topic subscription state so later requests, mutations, scheduled handlers, and queue consumers can publish to already-connected clients.
|
|
160
|
+
|
|
161
|
+
Delivery is at-most-once. Events are ordered within one topic, but events are not durably replayed after a disconnect. Use authoritative refetching or application-owned replay storage if missed events must be recovered.
|
|
@@ -5,7 +5,23 @@
|
|
|
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.
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## New Project
|
|
9
|
+
|
|
10
|
+
For a new Void app, start from the Void template. It includes the client, Void routes, Drizzle setup, live transport, auth wiring, and generated fate client setup.
|
|
11
|
+
|
|
12
|
+
```sh
|
|
13
|
+
vp create fate my-app --template void
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Use Vue instead of React with:
|
|
17
|
+
|
|
18
|
+
```sh
|
|
19
|
+
vp create fate my-app --template void --framework vue
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Existing Project
|
|
23
|
+
|
|
24
|
+
For an existing Void project, add the packages directly:
|
|
9
25
|
|
|
10
26
|
::: code-group
|
|
11
27
|
|
package/lib/vite.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Plugin } from "vite";
|
|
2
2
|
|
|
3
3
|
//#region src/viteTypes.d.ts
|
|
4
|
-
type FateViteTransport = 'graphql' | 'native' | 'trpc' | 'void';
|
|
4
|
+
type FateViteTransport = 'cloudflare' | 'graphql' | 'native' | 'trpc' | 'void';
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/vite.d.ts
|
|
7
7
|
type ClientRuntime = '@nkzw/fate' | 'react-fate' | 'vue-fate';
|
package/lib/vite.mjs
CHANGED
|
@@ -87,11 +87,20 @@ const createClientSource = ({ clientModule = "react-fate", moduleExports, module
|
|
|
87
87
|
});
|
|
88
88
|
if (transport === "native" || transport === "void") return createNativeClientSource({
|
|
89
89
|
clientModule,
|
|
90
|
+
cloudflareTransport: false,
|
|
90
91
|
moduleExports,
|
|
91
92
|
moduleName,
|
|
92
93
|
runtimeModuleName,
|
|
93
94
|
voidTransport: transport === "void"
|
|
94
95
|
});
|
|
96
|
+
if (transport === "cloudflare") return createNativeClientSource({
|
|
97
|
+
clientModule,
|
|
98
|
+
cloudflareTransport: true,
|
|
99
|
+
moduleExports,
|
|
100
|
+
moduleName,
|
|
101
|
+
runtimeModuleName,
|
|
102
|
+
voidTransport: false
|
|
103
|
+
});
|
|
95
104
|
const { appRouter, Root } = moduleExports;
|
|
96
105
|
const { roots, types } = createSchema(Object.values(moduleExports).filter(isDataView), Root ?? {});
|
|
97
106
|
const routerRecord = appRouter._def?.record ?? {};
|
|
@@ -412,7 +421,7 @@ type GeneratedCreateFateClient = typeof createFateClient;
|
|
|
412
421
|
${generatedClientTypes}
|
|
413
422
|
`;
|
|
414
423
|
};
|
|
415
|
-
const createNativeClientSource = ({ clientModule, moduleExports, moduleName, runtimeModuleName, voidTransport }) => {
|
|
424
|
+
const createNativeClientSource = ({ clientModule, cloudflareTransport, moduleExports, moduleName, runtimeModuleName, voidTransport }) => {
|
|
416
425
|
const { Root } = moduleExports;
|
|
417
426
|
const fateExportName = moduleExports.fate?.manifest ? "fate" : moduleExports.fateServer?.manifest ? "fateServer" : null;
|
|
418
427
|
const fateServer = fateExportName ? moduleExports[fateExportName] : null;
|
|
@@ -510,7 +519,17 @@ const createVoidFetch = (options: {
|
|
|
510
519
|
});
|
|
511
520
|
};
|
|
512
521
|
` : "";
|
|
513
|
-
const
|
|
522
|
+
const cloudflareHelpers = cloudflareTransport ? `
|
|
523
|
+
const defaultCloudflareFateRpcPath = '/fate';
|
|
524
|
+
const defaultCloudflareFateLivePath = '/fate-live';
|
|
525
|
+
|
|
526
|
+
const getDefaultOrigin = () =>
|
|
527
|
+
typeof window === 'undefined' ? 'http://localhost' : window.location.origin;
|
|
528
|
+
|
|
529
|
+
const toEndpointUrl = (url: string | URL | undefined, path: string, origin: string | URL) =>
|
|
530
|
+
url ?? new URL(path, origin);
|
|
531
|
+
` : "";
|
|
532
|
+
const createClientOptions = voidTransport || cloudflareTransport ? `options: {
|
|
514
533
|
fetch?: typeof fetch;
|
|
515
534
|
headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
|
|
516
535
|
livePath?: string;
|
|
@@ -529,7 +548,7 @@ const createVoidFetch = (options: {
|
|
|
529
548
|
onLiveError?: (error: unknown) => void;
|
|
530
549
|
url: string | URL;
|
|
531
550
|
}`;
|
|
532
|
-
const clientSetup = voidTransport ? ` => {
|
|
551
|
+
const clientSetup = voidTransport || cloudflareTransport ? ` => {
|
|
533
552
|
const origin = options.origin ?? getDefaultOrigin();
|
|
534
553
|
|
|
535
554
|
return createClient<[GeneratedClientRoots, GeneratedClientMutations], typeof hydrationScope>({
|
|
@@ -538,16 +557,16 @@ const createVoidFetch = (options: {
|
|
|
538
557
|
onLiveError: options.onLiveError,
|
|
539
558
|
roots,
|
|
540
559
|
transport: createHTTPTransport<FateAPI>({
|
|
541
|
-
fetch: createVoidFetch(options),
|
|
560
|
+
fetch: ${voidTransport ? "createVoidFetch(options)" : "options.fetch"},
|
|
542
561
|
headers: options.headers,
|
|
543
|
-
live: ${hasLive ? "connectLiveStream" : "false"},
|
|
562
|
+
live: ${hasLive ? voidTransport ? "connectLiveStream" : "connectCloudflareFateStream" : "false"},
|
|
544
563
|
liveRetryMs: options.liveRetryMs,
|
|
545
564
|
liveUrl: toEndpointUrl(
|
|
546
565
|
options.liveUrl,
|
|
547
|
-
options.livePath ?? defaultVoidFateLivePath,
|
|
566
|
+
options.livePath ?? ${voidTransport ? "defaultVoidFateLivePath" : "defaultCloudflareFateLivePath"},
|
|
548
567
|
origin,
|
|
549
568
|
),
|
|
550
|
-
url: toEndpointUrl(options.url, options.rpcPath ?? defaultVoidFateRpcPath, origin),
|
|
569
|
+
url: toEndpointUrl(options.url, options.rpcPath ?? ${voidTransport ? "defaultVoidFateRpcPath" : "defaultCloudflareFateRpcPath"}, origin),
|
|
551
570
|
}),
|
|
552
571
|
types: ${typesBlock.trimStart()},
|
|
553
572
|
});
|
|
@@ -581,6 +600,7 @@ declare module '${clientDeclarationModule}' {
|
|
|
581
600
|
import type { ${importedTypes.join(", ")} } from '${moduleName}';
|
|
582
601
|
import { clientRoot, createClient, createHTTPTransport, mutation, type InferFateAPI } from '${clientModule}';
|
|
583
602
|
${voidTransport && hasLive ? "import { connectLiveStream } from 'void/live/client';\n" : ""}${voidServerFetch}
|
|
603
|
+
${cloudflareTransport && hasLive ? "import { connectCloudflareFateStream } from 'cf-fate/client';\n" : ""}${cloudflareHelpers}
|
|
584
604
|
|
|
585
605
|
type FateAPI = InferFateAPI<typeof fateServer>;
|
|
586
606
|
|