@nkzw/fate 1.5.0 → 1.5.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 +5 -7
- package/docs/api/classes/FateClient.md +38 -38
- 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/index.md +2 -0
- package/docs/api/interfaces/FateThenable.md +3 -3
- package/docs/api/interfaces/Persistence.md +1 -19
- package/docs/api/interfaces/PersistenceSession.md +10 -10
- package/docs/api/interfaces/Transport.md +8 -8
- 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 +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/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/MutationIdentity.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/PersistedMutationStatus.md +5 -0
- package/docs/api/type-aliases/PersistenceSnapshot.md +2 -2
- 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 +2 -2
- package/docs/api/type-aliases/RequestPersistenceOptions.md +5 -0
- package/docs/api/type-aliases/RequestResult.md +1 -1
- package/docs/api/type-aliases/Selection.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/guide/persistence.md +5 -7
- package/lib/{executor-DoiTBiVv.d.mts → executor-oPTYqgQV.d.mts} +1 -1
- package/lib/{graphqlTransport-DGLYyRxL.d.mts → graphqlTransport-CGYE4NdD.d.mts} +1 -1
- package/lib/graphqlTransport.d.mts +1 -1
- package/lib/idempotency-types-DuqJ7KSd.d.mts +16 -0
- package/lib/idempotency.d.mts +7 -7
- package/lib/index.d.mts +5 -5
- package/lib/index.mjs +25 -15
- package/lib/{list-BRT1VtiT.d.mts → list-5hrTVoiB.d.mts} +1 -1
- package/lib/list.d.mts +1 -1
- package/lib/persistence.d.mts +20 -18
- package/lib/persistence.mjs +553 -352
- package/lib/{record-DITM4zb_.d.mts → record-Dxjvpsep.d.mts} +3 -3
- package/lib/server/drizzle.d.mts +2 -2
- package/lib/server/prisma.d.mts +2 -2
- package/lib/server.d.mts +3 -3
- package/lib/{store-CeatPJeK.mjs → store-CakBBzWG.mjs} +47 -11
- package/lib/{transport-DqjhjLfC.d.mts → transport-DR0fwleU.d.mts} +29 -16
- package/package.json +1 -1
- package/lib/idempotency-types-CqA-BFpn.d.mts +0 -15
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **MutationIdentifier**\<`T`, `I`, `R`\> = [`MutationDefinition`](MutationDefinition.md)\<`T`, `I`, `R`\> & `Readonly`\<\{ `key`: `string`; \}\>
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:473](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:473](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L473)
|
|
6
6
|
|
|
7
7
|
## Type Parameters
|
|
8
8
|
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
> **MutationIdentity** = `Readonly`\<\{ `id`: `string`; `replayOnly?`: `true`; `scope`: `string`; \}\>
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/persistence-types.ts:7](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/persistence-types.ts:7](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/persistence-types.ts#L7)
|
|
6
6
|
|
|
7
7
|
Identity of one logical mutation, reused across every delivery attempt.
|
|
@@ -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:477](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:477](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L477)
|
|
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:480](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:480](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L480)
|
|
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:365](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:365](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L365)
|
|
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:130](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:130](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L130)
|
|
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:131](https://github.com/nkzw-tech/fate/blob/
|
|
15
|
+
Defined in: [packages/fate/src/types.ts:131](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L131)
|
|
16
16
|
|
|
17
17
|
***
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ Defined in: [packages/fate/src/types.ts:131](https://github.com/nkzw-tech/fate/b
|
|
|
20
20
|
|
|
21
21
|
> **hasPrevious**: `boolean`
|
|
22
22
|
|
|
23
|
-
Defined in: [packages/fate/src/types.ts:132](https://github.com/nkzw-tech/fate/blob/
|
|
23
|
+
Defined in: [packages/fate/src/types.ts:132](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L132)
|
|
24
24
|
|
|
25
25
|
***
|
|
26
26
|
|
|
@@ -28,7 +28,7 @@ Defined in: [packages/fate/src/types.ts:132](https://github.com/nkzw-tech/fate/b
|
|
|
28
28
|
|
|
29
29
|
> `optional` **nextCursor?**: `string`
|
|
30
30
|
|
|
31
|
-
Defined in: [packages/fate/src/types.ts:133](https://github.com/nkzw-tech/fate/blob/
|
|
31
|
+
Defined in: [packages/fate/src/types.ts:133](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L133)
|
|
32
32
|
|
|
33
33
|
***
|
|
34
34
|
|
|
@@ -36,4 +36,4 @@ Defined in: [packages/fate/src/types.ts:133](https://github.com/nkzw-tech/fate/b
|
|
|
36
36
|
|
|
37
37
|
> `optional` **previousCursor?**: `string`
|
|
38
38
|
|
|
39
|
-
Defined in: [packages/fate/src/types.ts:134](https://github.com/nkzw-tech/fate/blob/
|
|
39
|
+
Defined in: [packages/fate/src/types.ts:134](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L134)
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Type Alias: PersistedMutationStatus
|
|
2
|
+
|
|
3
|
+
> **PersistedMutationStatus** = `Readonly`\<\{ `error?`: `string`; `id`: `string`; `input`: `unknown`; `name`: `string`; `status`: `"queued"` \| `"sending"` \| `"failed"`; \}\>
|
|
4
|
+
|
|
5
|
+
Defined in: [packages/fate/src/persistence-types.ts:20](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/persistence-types.ts#L20)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Type Alias: PersistenceSnapshot
|
|
2
2
|
|
|
3
|
-
> **PersistenceSnapshot** = `Readonly`\<\{ `error?`: `Error`; `mutations`: `ReadonlyArray
|
|
3
|
+
> **PersistenceSnapshot** = `Readonly`\<\{ `error?`: `Error`; `mutations`: `ReadonlyArray`\<[`PersistedMutationStatus`](PersistedMutationStatus.md)\>; `status`: `"restoring"` \| `"ready"` \| `"error"` \| `"disposed"`; \}\>
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/persistence-types.ts:
|
|
5
|
+
Defined in: [packages/fate/src/persistence-types.ts:28](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/persistence-types.ts#L28)
|
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
> **Request** = `Record`\<`string`, `RequestItem`\>
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:377](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:377](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L377)
|
|
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:
|
|
5
|
+
Defined in: [packages/fate/src/client.ts:96](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/client.ts#L96)
|
|
6
6
|
|
|
7
7
|
Strategy used when resolving a request.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Type Alias: RequestOptions
|
|
2
2
|
|
|
3
|
-
> **RequestOptions** = `Readonly`\<\{ `mode?`: [`RequestMode`](RequestMode.md); `persist?`:
|
|
3
|
+
> **RequestOptions** = `Readonly`\<\{ `mode?`: [`RequestMode`](RequestMode.md); `persist?`: [`RequestPersistenceOptions`](RequestPersistenceOptions.md); \}\>
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/client.ts:
|
|
5
|
+
Defined in: [packages/fate/src/client.ts:107](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/client.ts#L107)
|
|
6
6
|
|
|
7
7
|
Request options that affect how requests are fetched and retained.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Type Alias: RequestPersistenceOptions
|
|
2
|
+
|
|
3
|
+
> **RequestPersistenceOptions** = `Readonly`\<\{ `maxAge`: `number`; \}\>
|
|
4
|
+
|
|
5
|
+
Defined in: [packages/fate/src/persistence-types.ts:34](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/persistence-types.ts#L34)
|
|
@@ -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:423](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:423](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L423)
|
|
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:228](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:228](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L228)
|
|
6
6
|
|
|
7
7
|
Declarative selection of the fields a view needs from an entity.
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **TypeConfig** = `object`
|
|
4
4
|
|
|
5
|
-
Defined in: [packages/fate/src/types.ts:123](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:123](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L123)
|
|
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:124](https://github.com/nkzw-tech/fate/blob/
|
|
15
|
+
Defined in: [packages/fate/src/types.ts:124](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L124)
|
|
16
16
|
|
|
17
17
|
***
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ Defined in: [packages/fate/src/types.ts:124](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:125](https://github.com/nkzw-tech/fate/blob/
|
|
23
|
+
Defined in: [packages/fate/src/types.ts:125](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L125)
|
|
24
24
|
|
|
25
25
|
#### Parameters
|
|
26
26
|
|
|
@@ -38,4 +38,4 @@ Defined in: [packages/fate/src/types.ts:125](https://github.com/nkzw-tech/fate/b
|
|
|
38
38
|
|
|
39
39
|
> **type**: `string`
|
|
40
40
|
|
|
41
|
-
Defined in: [packages/fate/src/types.ts:126](https://github.com/nkzw-tech/fate/blob/
|
|
41
|
+
Defined in: [packages/fate/src/types.ts:126](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L126)
|
|
@@ -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:244](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:244](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L244)
|
|
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:260](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:260](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L260)
|
|
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:334](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:334](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L334)
|
|
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:337](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:337](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L337)
|
|
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:107](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:107](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L107)
|
|
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:340](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:340](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L340)
|
|
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:270](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:270](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L270)
|
|
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:55](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:55](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L55)
|
|
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:19](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:19](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L19)
|
|
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:22](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:22](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L22)
|
|
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:25](https://github.com/nkzw-tech/fate/blob/
|
|
5
|
+
Defined in: [packages/fate/src/types.ts:25](https://github.com/nkzw-tech/fate/blob/4d2c828cce4c513c8e424ff1ffe320bb387c49f2/packages/fate/src/types.ts#L25)
|
|
6
6
|
|
|
7
7
|
Symbol attached to deferred values returned from masked views.
|
|
@@ -16,13 +16,13 @@ Then pass `persistence` when creating the client:
|
|
|
16
16
|
|
|
17
17
|
```tsx
|
|
18
18
|
import { createPersistence } from '@nkzw/fate/persistence';
|
|
19
|
-
import {
|
|
19
|
+
import { createIndexedDBStorage } from '@nkzw/fate-indexeddb';
|
|
20
20
|
import { createFateClient } from 'react-fate/client';
|
|
21
21
|
|
|
22
22
|
const fate = createFateClient({
|
|
23
23
|
persistence: createPersistence({
|
|
24
24
|
key: `workspace:${workspaceId}:user:${userId}`,
|
|
25
|
-
storage:
|
|
25
|
+
storage: createIndexedDBStorage(),
|
|
26
26
|
}),
|
|
27
27
|
url: '/api/fate',
|
|
28
28
|
});
|
|
@@ -35,7 +35,7 @@ persistence: createPersistence({
|
|
|
35
35
|
key: `workspace:${workspaceId}:user:${userId}`,
|
|
36
36
|
maxAge: 24 * 60 * 60 * 1000,
|
|
37
37
|
maxBytes: 25 * 1024 * 1024,
|
|
38
|
-
storage:
|
|
38
|
+
storage: createIndexedDBStorage(),
|
|
39
39
|
}),
|
|
40
40
|
```
|
|
41
41
|
|
|
@@ -207,7 +207,7 @@ const durableHTTP = createHTTPTransport<MyAPI>({
|
|
|
207
207
|
|
|
208
208
|
const fate = createFateClient({
|
|
209
209
|
// ...your generated tRPC or GraphQL client options...
|
|
210
|
-
persistence: createPersistence({ key: accountKey, storage:
|
|
210
|
+
persistence: createPersistence({ key: accountKey, storage: createIndexedDBStorage() }),
|
|
211
211
|
mutateDurably: durableHTTP.mutateDurably,
|
|
212
212
|
});
|
|
213
213
|
```
|
|
@@ -297,7 +297,6 @@ The core persistence layer has no IndexedDB dependency. You can use another back
|
|
|
297
297
|
```ts
|
|
298
298
|
interface PersistenceStorage {
|
|
299
299
|
read(key: string): Promise<unknown>;
|
|
300
|
-
write(key: string, value: unknown): Promise<void>;
|
|
301
300
|
scan(
|
|
302
301
|
prefix: string,
|
|
303
302
|
after?: string,
|
|
@@ -312,9 +311,8 @@ interface PersistenceStorage {
|
|
|
312
311
|
Values use fate's hydration codec and can be stored as JSON. The adapter handles storage and coordination:
|
|
313
312
|
|
|
314
313
|
- `read` returns the saved value for a key.
|
|
315
|
-
- `write` replaces one value atomically and resolves after it has committed.
|
|
316
314
|
- `scan` returns keys under a prefix in ascending order, strictly after the optional cursor, up to the limit (64 by default). Use your backend's ordered index to keep each scan small.
|
|
317
|
-
- `writeBatch` commits all entries atomically. An `undefined` value deletes the key.
|
|
315
|
+
- `writeBatch` commits all entries atomically and resolves after they have committed. An `undefined` value deletes the key. Use a one-entry batch for a single write.
|
|
318
316
|
- `exclusive` coordinates every tab or process sharing the backend. Different lock names are independent: fate holds a delivery lock during network work and acquires a separate write lock when updating storage. Your adapter must allow that nesting.
|
|
319
317
|
- `subscribe` notifies other clients after a change commits, including keys changed by `writeBatch`. Without notifications, clients check saved mutations during delivery attempts and explicit `retry()` calls.
|
|
320
318
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { b as AnyRecord, lt as QueryProcedure } from "./transport-DR0fwleU.mjs";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region src/server/dataView.d.ts
|
|
4
4
|
declare const dataViewFieldsKey: unique symbol;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { B as MutationShape, k as Entity, q as TypeConfig, t as Transport } from "./transport-DR0fwleU.mjs";
|
|
2
2
|
//#region src/graphqlTransport.d.ts
|
|
3
3
|
type TransportMutations = Record<string, MutationShape>;
|
|
4
4
|
type EmptyTransportMutations = Record<never, MutationShape>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as GraphQLTransportOptions, i as GraphQLMutationOutput, n as GraphQLMutationInput, o as createGraphQLTransport, r as GraphQLMutationMap, s as graphqlMutation, t as GraphQLMutationDefinition } from "./graphqlTransport-
|
|
1
|
+
import { a as GraphQLTransportOptions, i as GraphQLMutationOutput, n as GraphQLMutationInput, o as createGraphQLTransport, r as GraphQLMutationMap, s as graphqlMutation, t as GraphQLMutationDefinition } from "./graphqlTransport-CGYE4NdD.mjs";
|
|
2
2
|
export { GraphQLMutationDefinition, GraphQLMutationInput, GraphQLMutationMap, GraphQLMutationOutput, GraphQLTransportOptions, createGraphQLTransport, graphqlMutation };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { r as MutationIdentity } from "./transport-DR0fwleU.mjs";
|
|
2
|
+
//#region src/server/idempotency-types.d.ts
|
|
3
|
+
/** Server enforcement for a durable mutation. The resolver must use the supplied context. */
|
|
4
|
+
interface MutationIdempotency<Context> {
|
|
5
|
+
execute<Result>(options: MutationIdempotencyOptions<Context, Result>): Promise<Result>;
|
|
6
|
+
}
|
|
7
|
+
type MutationIdempotencyOptions<Context, Result> = Readonly<{
|
|
8
|
+
ctx: Context;
|
|
9
|
+
identity: MutationIdentity;
|
|
10
|
+
input: unknown;
|
|
11
|
+
name: string;
|
|
12
|
+
resolve(ctx: Context): Promise<Result>;
|
|
13
|
+
select: ReadonlyArray<string>;
|
|
14
|
+
}>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { MutationIdempotencyOptions as n, MutationIdempotency as t };
|
package/lib/idempotency.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as MutationIdempotency } from "./idempotency-types-
|
|
1
|
+
import { _ as encodeHydrationValue } from "./transport-DR0fwleU.mjs";
|
|
2
|
+
import { n as MutationIdempotencyOptions, t as MutationIdempotency } from "./idempotency-types-DuqJ7KSd.mjs";
|
|
3
3
|
//#region src/idempotency.d.ts
|
|
4
4
|
type MutationReceipt = Readonly<{
|
|
5
5
|
fingerprint: string;
|
|
@@ -10,17 +10,17 @@ type MutationReceipt = Readonly<{
|
|
|
10
10
|
* The adapter must serialize concurrent calls for the same scope and ID,
|
|
11
11
|
* including calls from different processes. Receipts must not expire.
|
|
12
12
|
*/
|
|
13
|
-
interface IdempotencyStore<Context> {
|
|
13
|
+
interface IdempotencyStore<Context, TransactionContext extends Context = Context> {
|
|
14
14
|
transaction<T>(context: Context, scope: string, id: string, run: (transaction: {
|
|
15
|
-
context:
|
|
15
|
+
context: TransactionContext;
|
|
16
16
|
read(): Promise<MutationReceipt | undefined>;
|
|
17
17
|
write(receipt: MutationReceipt): Promise<void>;
|
|
18
18
|
}) => Promise<T>): Promise<T>;
|
|
19
19
|
}
|
|
20
20
|
/** Enforces durable deduplication using the application's own transaction adapter. */
|
|
21
|
-
declare function createMutationIdempotency<Context>(options: {
|
|
21
|
+
declare function createMutationIdempotency<Context, TransactionContext extends Context = Context>(options: {
|
|
22
22
|
scope(context: Context): string | Promise<string>;
|
|
23
|
-
store: IdempotencyStore<Context>;
|
|
23
|
+
store: IdempotencyStore<Context, TransactionContext>;
|
|
24
24
|
}): MutationIdempotency<Context>;
|
|
25
25
|
//#endregion
|
|
26
|
-
export { IdempotencyStore, type MutationIdempotency, MutationReceipt, createMutationIdempotency };
|
|
26
|
+
export { IdempotencyStore, type MutationIdempotency, type MutationIdempotencyOptions, MutationReceipt, createMutationIdempotency };
|
package/lib/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { $ as
|
|
2
|
-
import { a as GraphQLTransportOptions, i as GraphQLMutationOutput, n as GraphQLMutationInput, o as createGraphQLTransport, r as GraphQLMutationMap, s as graphqlMutation, t as GraphQLMutationDefinition } from "./graphqlTransport-
|
|
3
|
-
import { C as liveGlobalConnectionTopic, S as liveEntityTopic, a as FateProtocolRequest, i as FateOperation, n as FateLiveConnectionEvent, o as FateProtocolResponse, r as FateLiveEvent, t as isRecord, u as InferFateAPI, x as liveConnectionTopic } from "./record-
|
|
4
|
-
import { n as getListEntries, t as ListEntry } from "./list-
|
|
1
|
+
import { $ as ViewRef, A as EntityId, B as MutationShape, C as ConnectionTag, D as DeferredSelection, E as DeferredMetadata, F as MutationDefinition, G as RootDefinition, H as Pagination, I as MutationEntity, J as TypeName, K as Selection, L as MutationIdentifier, M as FateThenable, N as ListItem, O as DeferredTag, P as Mask, Q as ViewEntityName, R as MutationInput, S as ConnectionRef, T as Deferred, U as Request$1, V as NodesItem, W as RequestResult, X as ViewData, Y as View, Z as ViewEntity, a as Persistence, at as isViewTag, b as AnyRecord, c as RequestPersistenceOptions, d as RequestMode, et as ViewSelection, f as RequestOptions, g as HydrationLimits, h as HydrateOptions, i as PersistedMutationStatus, it as __FateSelectionBrand, j as FateRoots, k as Entity, l as DeferredSnapshot, m as FateDehydratedState, n as createTRPCTransport, nt as ViewTag, o as PersistenceSession, ot as FateMutations, p as createClient, q as TypeConfig, r as MutationIdentity, rt as __FateEntityBrand, s as PersistenceSnapshot, st as mutation, t as Transport, tt as ViewSnapshot, u as FateClient, v as List, w as DeferTag, x as ConnectionMetadata, y as getSelectionPlan, z as MutationResult } from "./transport-DR0fwleU.mjs";
|
|
2
|
+
import { a as GraphQLTransportOptions, i as GraphQLMutationOutput, n as GraphQLMutationInput, o as createGraphQLTransport, r as GraphQLMutationMap, s as graphqlMutation, t as GraphQLMutationDefinition } from "./graphqlTransport-CGYE4NdD.mjs";
|
|
3
|
+
import { C as liveGlobalConnectionTopic, S as liveEntityTopic, a as FateProtocolRequest, i as FateOperation, n as FateLiveConnectionEvent, o as FateProtocolResponse, r as FateLiveEvent, t as isRecord, u as InferFateAPI, x as liveConnectionTopic } from "./record-Dxjvpsep.mjs";
|
|
4
|
+
import { n as getListEntries, t as ListEntry } from "./list-5hrTVoiB.mjs";
|
|
5
5
|
//#region src/defer.d.ts
|
|
6
6
|
declare function defer<S>(selection: S): DeferredSelection<S>;
|
|
7
7
|
declare const isDeferred: (value: unknown) => value is Deferred<unknown>;
|
|
@@ -84,4 +84,4 @@ type SelectionValidation<T extends Entity, S extends Selection<T>> = Exclude<key
|
|
|
84
84
|
*/
|
|
85
85
|
declare function view<T extends Entity>(): <S extends Selection<T>>(select: S & SelectionValidation<T, S>) => View<T, S>;
|
|
86
86
|
//#endregion
|
|
87
|
-
export { type ConnectionMetadata, type ConnectionRef, ConnectionTag, DeferTag, type Deferred, type DeferredMetadata, type DeferredSelection, type DeferredSnapshot, DeferredTag, type Entity, type EntityId, FateClient, type FateDehydratedState, type FateLiveConnectionEvent, type FateLiveEvent, type FateMutations, type FateOperation, type FateProtocolRequest, type FateProtocolResponse, type AnyRecord as FateRecord, type FateRoots, type FateThenable, type GraphQLMutationDefinition, type GraphQLMutationInput, type GraphQLMutationMap, type GraphQLMutationOutput, type GraphQLTransportOptions, type HydrateOptions, type HydrationLimits, type InferFateAPI, type List, type ListEntry, type ListItem, type Mask, type MutationDefinition, type MutationEntity, type MutationIdentifier, type MutationIdentity, type MutationInput, type MutationResult, type NodesItem, type Pagination, type Persistence, type PersistenceSession, type PersistenceSnapshot, type Request$1 as Request, type RequestMode, type RequestOptions, type RequestResult, type Selection, type Transport, type TypeConfig, type View, type ViewData, type ViewEntity, type ViewEntityName, type ViewRef, type ViewSelection, type ViewSnapshot, type ViewTag, clientRoot, createClient, createGraphQLTransport, createHTTPTransport, createTRPCTransport, defer, getDeferredMetadata, getListEntries, getSelectionPlan, graphqlMutation, isDeferred, isRecord, isViewTag, liveConnectionTopic, liveEntityTopic, liveGlobalConnectionTopic, mutation, toEntityId, view };
|
|
87
|
+
export { type ConnectionMetadata, type ConnectionRef, ConnectionTag, DeferTag, type Deferred, type DeferredMetadata, type DeferredSelection, type DeferredSnapshot, DeferredTag, type Entity, type EntityId, FateClient, type FateDehydratedState, type FateLiveConnectionEvent, type FateLiveEvent, type FateMutations, type FateOperation, type FateProtocolRequest, type FateProtocolResponse, type AnyRecord as FateRecord, type FateRoots, type FateThenable, type GraphQLMutationDefinition, type GraphQLMutationInput, type GraphQLMutationMap, type GraphQLMutationOutput, type GraphQLTransportOptions, type HydrateOptions, type HydrationLimits, type InferFateAPI, type List, type ListEntry, type ListItem, type Mask, type MutationDefinition, type MutationEntity, type MutationIdentifier, type MutationIdentity, type MutationInput, type MutationResult, type NodesItem, type Pagination, type PersistedMutationStatus, type Persistence, type PersistenceSession, type PersistenceSnapshot, type Request$1 as Request, type RequestMode, type RequestOptions, type RequestPersistenceOptions, type RequestResult, type Selection, type Transport, type TypeConfig, type View, type ViewData, type ViewEntity, type ViewEntityName, type ViewRef, type ViewSelection, type ViewSnapshot, type ViewTag, clientRoot, createClient, createGraphQLTransport, createHTTPTransport, createTRPCTransport, defer, getDeferredMetadata, getListEntries, getSelectionPlan, graphqlMutation, isDeferred, isRecord, isViewTag, liveConnectionTopic, liveEntityTopic, liveGlobalConnectionTopic, mutation, toEntityId, view };
|
package/lib/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as isRecord } from "./record-B07VwXd-.mjs";
|
|
2
2
|
import { a as hashArgs, c as scopeArgsPayload, i as filterConnectionArgs, r as combineArgsPayload, s as resolvedArgsFromPlan, t as applyArgsPayloadToPlan } from "./args-CRLIRl_v.mjs";
|
|
3
3
|
import { _ as isNodesItem, a as createNodeRef, c as ConnectionTag, f as RootKind, g as isNodeItem, i as resolveHydrationLimits, l as DeferTag, m as ViewsTag, o as getNodeRefId, r as encodeHydrationValue, s as isNodeRef, t as decodeClientHydrationState, u as DeferredTag, v as isQueryItem, y as isViewTag } from "./hydration-DPZRJgnu.mjs";
|
|
4
|
-
import { C as isDeferredSelection, S as isDeferred, _ as view, a as mutation, b as getDeferredMetadata, c as getDeferredSelectionPlan, d as createRefWithViewNames, f as getRootViewNames, g as getViewPayloads, h as getViewNames, l as getSelectionPlan, m as toEntityId, n as getListKey, p as parseEntityId, r as mergePreservingExisting, s as wrapMutation, t as Store, u as assignViewTag, v as createDeferred, x as getDeferredSelection, y as defer } from "./store-
|
|
4
|
+
import { C as isDeferredSelection, S as isDeferred, _ as view, a as mutation, b as getDeferredMetadata, c as getDeferredSelectionPlan, d as createRefWithViewNames, f as getRootViewNames, g as getViewPayloads, h as getViewNames, l as getSelectionPlan, m as toEntityId, n as getListKey, p as parseEntityId, r as mergePreservingExisting, s as wrapMutation, t as Store, u as assignViewTag, v as createDeferred, x as getDeferredSelection, y as defer } from "./store-CakBBzWG.mjs";
|
|
5
5
|
import { t as getListEntries } from "./list-_6fXYLtJ.mjs";
|
|
6
6
|
import { n as errorCodeFromStatus, t as FateRequestError } from "./protocol-DS5sf6sd.mjs";
|
|
7
7
|
import { n as graphqlMutation, t as createGraphQLTransport } from "./graphqlTransport-DmheG3AO.mjs";
|
|
@@ -478,7 +478,7 @@ var FateClient = class {
|
|
|
478
478
|
this.store = new Store((ids) => {
|
|
479
479
|
for (const id of ids) this.viewDataCache.invalidate(id);
|
|
480
480
|
this.runPendingGarbageCollection();
|
|
481
|
-
}, (
|
|
481
|
+
}, (change) => this.persistenceRuntime?.changed(change));
|
|
482
482
|
this.viewDataCache = new ViewDataCache(() => !this.store.isRebasing);
|
|
483
483
|
this.liveConnectionInvalidationToken = 0;
|
|
484
484
|
this.persistenceDisposal = options.persistence ? new AbortController() : void 0;
|
|
@@ -508,7 +508,8 @@ var FateClient = class {
|
|
|
508
508
|
setNestedValue(this.actions, key, async (_previousState, data) => data === "reset" ? null : await this.mutationMap[key](data));
|
|
509
509
|
}
|
|
510
510
|
this.initializeParentLists();
|
|
511
|
-
this.
|
|
511
|
+
this.persistenceRuntime = options.persistence?.attach(this);
|
|
512
|
+
this.persistence = this.persistenceRuntime;
|
|
512
513
|
}
|
|
513
514
|
initializeParentLists() {
|
|
514
515
|
for (const config of this.types.values()) {
|
|
@@ -704,6 +705,11 @@ var FateClient = class {
|
|
|
704
705
|
if (this.mutationEntities?.size) this.requireDurableMutationTransport();
|
|
705
706
|
}
|
|
706
707
|
/** @internal */
|
|
708
|
+
persistMutation(command) {
|
|
709
|
+
if (!this.persistenceRuntime) throw new Error("fate: Persistence is not configured.");
|
|
710
|
+
return this.persistenceRuntime.mutate(command);
|
|
711
|
+
}
|
|
712
|
+
/** @internal */
|
|
707
713
|
assertPersistenceActive() {
|
|
708
714
|
if (this.persistenceDisposal?.signal.aborted || this.persistence?.getSnapshot().status === "disposed") throw new Error("fate: Persistence was disposed.");
|
|
709
715
|
}
|
|
@@ -828,7 +834,8 @@ var FateClient = class {
|
|
|
828
834
|
const pendingPromise = this.pending.get(key) || null;
|
|
829
835
|
if (pendingPromise) return pendingPromise;
|
|
830
836
|
const promise = this.trackPendingRequest(async () => {
|
|
831
|
-
|
|
837
|
+
const persistence = this.persistenceRuntime;
|
|
838
|
+
if (persistence) {
|
|
832
839
|
const persistedRequest = {
|
|
833
840
|
items: [{
|
|
834
841
|
ids: [id],
|
|
@@ -841,11 +848,11 @@ var FateClient = class {
|
|
|
841
848
|
}],
|
|
842
849
|
key: `view:${key}`
|
|
843
850
|
};
|
|
844
|
-
await
|
|
851
|
+
await persistence.restoreRequest(persistedRequest);
|
|
845
852
|
const remaining = this.store.missingForSelection(entityId, selectedPaths);
|
|
846
853
|
if (remaining.size) {
|
|
847
854
|
await this.fetchByIdAndNormalize(type, [id], remaining, plan);
|
|
848
|
-
|
|
855
|
+
persistence.fetched({
|
|
849
856
|
...persistedRequest,
|
|
850
857
|
items: persistedRequest.items.map((item) => ({
|
|
851
858
|
...item,
|
|
@@ -1433,15 +1440,16 @@ var FateClient = class {
|
|
|
1433
1440
|
}
|
|
1434
1441
|
requestWithDescriptor(descriptor, mode, { revalidateExisting }, options) {
|
|
1435
1442
|
this.assertPersistenceActive();
|
|
1436
|
-
|
|
1443
|
+
const persistence = this.persistenceRuntime;
|
|
1444
|
+
if (persistence && options?.persist && (!Number.isSafeInteger(options.persist.maxAge) || options.persist.maxAge < 0 || options.persist.maxAge > Number.MAX_SAFE_INTEGER - Date.now())) throw new Error("fate: Persistence maxAge must be a non-negative finite duration.");
|
|
1437
1445
|
const requestKey = descriptor.key;
|
|
1438
1446
|
const existingRequest = this.requests.get(requestKey)?.get(mode);
|
|
1439
1447
|
if (existingRequest) {
|
|
1440
|
-
if (
|
|
1448
|
+
if (persistence && options?.persist) {
|
|
1441
1449
|
const executionOptions = this.requestExecutionOptions.get(existingRequest.descriptor);
|
|
1442
1450
|
if (executionOptions) executionOptions.persist = { ...options.persist };
|
|
1443
1451
|
}
|
|
1444
|
-
if (
|
|
1452
|
+
if (persistence && options?.persist && existingRequest.status === "fulfilled") persistence.used(existingRequest.descriptor, options.persist);
|
|
1445
1453
|
const isFulfilledCacheFirstWithMissingData = mode === "cache-first" && existingRequest.status === "fulfilled" && !this.hasRequestData(existingRequest.descriptor);
|
|
1446
1454
|
if (existingRequest.status !== "pending" && (isFulfilledCacheFirstWithMissingData || revalidateExisting && (mode === "network-only" || mode === "stale-while-revalidate" || mode === "cache-first" && existingRequest.status === "rejected"))) this.executeRequestHandle(existingRequest, mode, options);
|
|
1447
1455
|
return existingRequest;
|
|
@@ -1562,17 +1570,18 @@ var FateClient = class {
|
|
|
1562
1570
|
}
|
|
1563
1571
|
}
|
|
1564
1572
|
executeRequestHandle(handle, mode, options) {
|
|
1573
|
+
const persistence = this.persistenceRuntime;
|
|
1565
1574
|
const executionOptions = {
|
|
1566
1575
|
fetchAll: mode !== "cache-first",
|
|
1567
1576
|
persist: options?.persist ? { ...options.persist } : void 0
|
|
1568
1577
|
};
|
|
1569
|
-
if (
|
|
1578
|
+
if (persistence) this.requestExecutionOptions.set(handle.descriptor, executionOptions);
|
|
1570
1579
|
const execute = () => {
|
|
1571
1580
|
this.assertPersistenceActive();
|
|
1572
1581
|
if (mode === "stale-while-revalidate") return this.handleStoreAndNetworkRequest(handle.descriptor, executionOptions);
|
|
1573
1582
|
return this.executeRequest(handle.descriptor, executionOptions).then(() => this.getRequestResultFromDescriptor(handle.descriptor));
|
|
1574
1583
|
};
|
|
1575
|
-
handle.start(
|
|
1584
|
+
handle.start(persistence ? this.withPersistenceLifecycle(() => persistence.ready.then(() => mode === "network-only" ? void 0 : persistence.restoreRequest(handle.descriptor)).then(execute)) : execute());
|
|
1576
1585
|
}
|
|
1577
1586
|
markRecordReferences(record, markRecord) {
|
|
1578
1587
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -1625,7 +1634,7 @@ var FateClient = class {
|
|
|
1625
1634
|
return await this.withPersistenceLifecycle(request);
|
|
1626
1635
|
} finally {
|
|
1627
1636
|
this.pendingNetworkRequests -= 1;
|
|
1628
|
-
this.
|
|
1637
|
+
this.persistenceRuntime?.changed();
|
|
1629
1638
|
}
|
|
1630
1639
|
});
|
|
1631
1640
|
}
|
|
@@ -1714,12 +1723,13 @@ var FateClient = class {
|
|
|
1714
1723
|
fetchedItems.push(item);
|
|
1715
1724
|
}
|
|
1716
1725
|
await Promise.all([...promises, ...Array.from(groups.values()).map((group) => group.ids.length ? this.fetchByIdAndNormalize(group.type, group.ids, group.fields, group.plan) : Promise.resolve())]);
|
|
1717
|
-
|
|
1718
|
-
|
|
1726
|
+
const persistence = this.persistenceRuntime;
|
|
1727
|
+
if (persistence) {
|
|
1728
|
+
if (fetchedItems.length) persistence.fetched(fetchedAll ? request : {
|
|
1719
1729
|
items: fetchedItems,
|
|
1720
1730
|
key: `partial:${JSON.stringify([request.key, fetchedItems.map((item) => [item.name, "ids" in item ? item.ids : null])])}`
|
|
1721
1731
|
}, options.persist);
|
|
1722
|
-
if (!fetchedItems.length || !fetchedAll)
|
|
1732
|
+
if (!fetchedItems.length || !fetchedAll) persistence.used(request, options.persist);
|
|
1723
1733
|
}
|
|
1724
1734
|
}
|
|
1725
1735
|
hasRequestData(request) {
|
package/lib/list.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as getListEntries, t as ListEntry } from "./list-
|
|
1
|
+
import { n as getListEntries, t as ListEntry } from "./list-5hrTVoiB.mjs";
|
|
2
2
|
export { ListEntry, getListEntries };
|