@nkzw/fate 1.3.3 → 1.5.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 +326 -0
- package/docs/api/classes/FateClient.md +51 -199
- 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 +5 -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 +4 -1
- package/docs/api/interfaces/FateThenable.md +3 -3
- package/docs/api/interfaces/Persistence.md +23 -0
- package/docs/api/interfaces/PersistenceSession.md +109 -0
- package/docs/api/interfaces/Transport.md +46 -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 +2 -2
- 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 +19 -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/MutationIdentity.md +7 -0
- 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/PersistenceSnapshot.md +5 -0
- 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/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/getting-started.md +2 -0
- package/docs/guide/persistence.md +323 -0
- package/lib/{liveTopics-uVP0LG-Q.mjs → args-CRLIRl_v.mjs} +1 -59
- package/lib/cli.d.mts +1 -1
- package/lib/{executor-C8HNogYG.d.mts → executor-DoiTBiVv.d.mts} +18 -65
- package/lib/{graphqlTransport-DskuXeUP.d.mts → graphqlTransport-DGLYyRxL.d.mts} +4 -14
- package/lib/{graphqlTransport-DSBVS2Fq.mjs → graphqlTransport-DmheG3AO.mjs} +3 -2
- package/lib/graphqlTransport.d.mts +1 -1
- package/lib/graphqlTransport.mjs +1 -1
- package/lib/hydration-DPZRJgnu.mjs +273 -0
- package/lib/idempotency-types-CqA-BFpn.d.mts +15 -0
- package/lib/idempotency.d.mts +26 -0
- package/lib/idempotency.mjs +34 -0
- package/lib/index.d.mts +6 -15
- package/lib/index.mjs +560 -1774
- package/lib/{list-sI2UPhHc.d.mts → list-BRT1VtiT.d.mts} +1 -2
- package/lib/list.d.mts +1 -1
- package/lib/liveTopics-DuFkDZQm.mjs +17 -0
- package/lib/persistence.d.mts +38 -0
- package/lib/persistence.mjs +1529 -0
- package/lib/protocol-DS5sf6sd.mjs +44 -0
- package/lib/{record-CZyyeLa3.d.mts → record-DITM4zb_.d.mts} +14 -19
- package/lib/server/drizzle.d.mts +45 -114
- package/lib/server/drizzle.mjs +2 -2
- package/lib/server/prisma.d.mts +52 -127
- package/lib/server/prisma.mjs +9 -8
- package/lib/server.d.mts +4 -16
- package/lib/server.mjs +21 -35
- package/lib/sortObjectKeys-yhuitEQZ.mjs +9 -0
- package/lib/{sourceRouter-DSaADXSf.mjs → sourceRouter-51POBlEE.mjs} +9 -6
- package/lib/store-CeatPJeK.mjs +1350 -0
- package/lib/{transport-DhaVVq4P.d.mts → transport-DqjhjLfC.d.mts} +672 -517
- package/lib/vite.d.mts +0 -1
- package/lib/vite.mjs +19 -11
- package/package.json +15 -5
- package/docs/api/type-aliases/Snapshot.md +0 -7
package/lib/server/prisma.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { S as ConnectionResult, c as SourceConfig, f as SourcePlan, k as DataView, l as SourceDefinition, o as DataViewModule, p as SourcePlanNode, s as OrderDirection, t as SourceRegistry } from "../executor-
|
|
3
|
-
|
|
1
|
+
import { st as QueryProcedure, v as AnyRecord } from "../transport-DqjhjLfC.mjs";
|
|
2
|
+
import { S as ConnectionResult, c as SourceConfig, f as SourcePlan, k as DataView, l as SourceDefinition, o as DataViewModule, p as SourcePlanNode, s as OrderDirection, t as SourceRegistry } from "../executor-DoiTBiVv.mjs";
|
|
4
3
|
//#region src/server/prisma.d.ts
|
|
5
4
|
type PrismaDelegate = {
|
|
6
5
|
findMany?: (args: any) => Promise<Array<AnyRecord>>;
|
|
@@ -27,37 +26,19 @@ type ViewProcedureInput<Item extends AnyRecord, ById extends boolean | undefined
|
|
|
27
26
|
view: ViewTarget<Item>;
|
|
28
27
|
};
|
|
29
28
|
type PrismaSourceAdapter<Context> = {
|
|
30
|
-
fetchById: <Item extends AnyRecord = AnyRecord>({
|
|
31
|
-
ctx,
|
|
32
|
-
extra,
|
|
33
|
-
id,
|
|
34
|
-
plan
|
|
35
|
-
}: {
|
|
29
|
+
fetchById: <Item extends AnyRecord = AnyRecord>({ ctx, extra, id, plan }: {
|
|
36
30
|
ctx: Context;
|
|
37
31
|
extra?: PrismaQueryExtra;
|
|
38
32
|
id: string;
|
|
39
33
|
plan: SourcePlan<Item, Context>;
|
|
40
34
|
}) => Promise<Item | null>;
|
|
41
|
-
fetchByIds: <Item extends AnyRecord = AnyRecord>({
|
|
42
|
-
ctx,
|
|
43
|
-
extra,
|
|
44
|
-
ids,
|
|
45
|
-
plan
|
|
46
|
-
}: {
|
|
35
|
+
fetchByIds: <Item extends AnyRecord = AnyRecord>({ ctx, extra, ids, plan }: {
|
|
47
36
|
ctx: Context;
|
|
48
37
|
extra?: PrismaQueryExtra;
|
|
49
38
|
ids: Array<string>;
|
|
50
39
|
plan: SourcePlan<Item, Context>;
|
|
51
40
|
}) => Promise<Array<Item>>;
|
|
52
|
-
fetchConnection: <Item extends AnyRecord = AnyRecord>({
|
|
53
|
-
ctx,
|
|
54
|
-
cursor,
|
|
55
|
-
direction,
|
|
56
|
-
extra,
|
|
57
|
-
plan,
|
|
58
|
-
skip,
|
|
59
|
-
take
|
|
60
|
-
}: {
|
|
41
|
+
fetchConnection: <Item extends AnyRecord = AnyRecord>({ ctx, cursor, direction, extra, plan, skip, take }: {
|
|
61
42
|
ctx: Context;
|
|
62
43
|
cursor?: string;
|
|
63
44
|
direction: 'backward' | 'forward';
|
|
@@ -102,40 +83,51 @@ type SourceInput = {
|
|
|
102
83
|
args?: Record<string, unknown>;
|
|
103
84
|
select: Iterable<string>;
|
|
104
85
|
};
|
|
105
|
-
declare const prismaConnectionArgs: ({
|
|
106
|
-
cursor,
|
|
107
|
-
direction,
|
|
108
|
-
node,
|
|
109
|
-
skip,
|
|
110
|
-
take
|
|
111
|
-
}: {
|
|
86
|
+
declare const prismaConnectionArgs: ({ cursor, direction, node, skip, take }: {
|
|
112
87
|
cursor?: string;
|
|
113
|
-
direction:
|
|
88
|
+
direction: 'backward' | 'forward';
|
|
114
89
|
node: SourcePlanNode<any, any>;
|
|
115
90
|
skip?: number;
|
|
116
91
|
take: number;
|
|
117
92
|
}) => {
|
|
118
|
-
orderBy: {
|
|
119
|
-
[x: string]: OrderDirection;
|
|
120
|
-
}[];
|
|
121
|
-
take: number;
|
|
122
93
|
cursor?: {
|
|
123
94
|
id: string;
|
|
124
95
|
} | undefined;
|
|
125
96
|
skip?: number | undefined;
|
|
97
|
+
orderBy: {
|
|
98
|
+
[x: string]: OrderDirection;
|
|
99
|
+
}[];
|
|
100
|
+
take: number;
|
|
126
101
|
};
|
|
127
|
-
declare function createPrismaSourceAdapter<Context>({
|
|
128
|
-
prisma,
|
|
129
|
-
views
|
|
130
|
-
}: PrismaSourceAdapterOptions<Context>): PrismaSourceAdapter<Context>;
|
|
102
|
+
declare function createPrismaSourceAdapter<Context>({ prisma, views }: PrismaSourceAdapterOptions<Context>): PrismaSourceAdapter<Context>;
|
|
131
103
|
declare const createPrismaSourceRegistry: <Context>(options: Parameters<typeof createPrismaSourceAdapter<Context>>[0]) => SourceRegistry<Context>;
|
|
132
|
-
declare function createPrismaFate<Context, Procedure extends ProcedureLike>({
|
|
133
|
-
procedure,
|
|
134
|
-
...options
|
|
135
|
-
}: Parameters<typeof createPrismaSourceAdapter<Context>>[0] & {
|
|
104
|
+
declare function createPrismaFate<Context, Procedure extends ProcedureLike>({ procedure, ...options }: Parameters<typeof createPrismaSourceAdapter<Context>>[0] & {
|
|
136
105
|
procedure: Procedure;
|
|
137
106
|
}): {
|
|
138
|
-
|
|
107
|
+
fetchById: <Item extends AnyRecord = AnyRecord>({ ctx, extra, id, plan }: {
|
|
108
|
+
ctx: Context;
|
|
109
|
+
extra?: PrismaQueryExtra;
|
|
110
|
+
id: string;
|
|
111
|
+
plan: SourcePlan<Item, Context>;
|
|
112
|
+
}) => Promise<Item | null>;
|
|
113
|
+
fetchByIds: <Item extends AnyRecord = AnyRecord>({ ctx, extra, ids, plan }: {
|
|
114
|
+
ctx: Context;
|
|
115
|
+
extra?: PrismaQueryExtra;
|
|
116
|
+
ids: Array<string>;
|
|
117
|
+
plan: SourcePlan<Item, Context>;
|
|
118
|
+
}) => Promise<Item[]>;
|
|
119
|
+
fetchConnection: <Item extends AnyRecord = AnyRecord>({ ctx, cursor, direction, extra, plan, skip, take }: {
|
|
120
|
+
ctx: Context;
|
|
121
|
+
cursor?: string;
|
|
122
|
+
direction: 'backward' | 'forward';
|
|
123
|
+
extra?: PrismaQueryExtra;
|
|
124
|
+
plan: SourcePlan<Item, Context>;
|
|
125
|
+
skip?: number;
|
|
126
|
+
take: number;
|
|
127
|
+
}) => Promise<Item[]>;
|
|
128
|
+
getSource: <Item extends AnyRecord = AnyRecord>(target: SourceTarget<Item>) => SourceDefinition<Item, unknown>;
|
|
129
|
+
registry: SourceRegistry<Context>;
|
|
130
|
+
connection: <TItem, TNode = TItem, TAdditionalInput extends import("zod").ZodObject<Record<string, import("zod").ZodTypeAny<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>, import("zod/v4/core").$strip> | undefined = undefined>(options: {
|
|
139
131
|
defaultSize?: number;
|
|
140
132
|
getCursor?: ((node: TNode) => string) | undefined;
|
|
141
133
|
input?: TAdditionalInput | undefined;
|
|
@@ -148,10 +140,10 @@ declare function createPrismaFate<Context, Procedure extends ProcedureLike>({
|
|
|
148
140
|
};
|
|
149
141
|
} ? TContext : unknown;
|
|
150
142
|
input: {
|
|
151
|
-
select: string[];
|
|
152
143
|
args?: Record<string, unknown> | undefined;
|
|
144
|
+
select: string[];
|
|
153
145
|
} & {
|
|
154
|
-
args?: ((Record<string, unknown> | undefined) & (TAdditionalInput extends import("zod").ZodObject<Record<string, import("zod").
|
|
146
|
+
args?: ((Record<string, unknown> | undefined) & (TAdditionalInput extends import("zod").ZodObject<Record<string, import("zod").ZodTypeAny<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>, import("zod/v4/core").$strip> ? import("zod").infer<TAdditionalInput> : object)) | undefined;
|
|
155
147
|
};
|
|
156
148
|
items: TItem[];
|
|
157
149
|
}) => TNode[] | Promise<TNode[]>) | undefined;
|
|
@@ -164,51 +156,46 @@ declare function createPrismaFate<Context, Procedure extends ProcedureLike>({
|
|
|
164
156
|
};
|
|
165
157
|
} ? TContext : unknown;
|
|
166
158
|
cursor?: string;
|
|
167
|
-
direction:
|
|
159
|
+
direction: 'forward' | 'backward';
|
|
168
160
|
input: {
|
|
169
|
-
select: string[];
|
|
170
161
|
args?: Record<string, unknown> | undefined;
|
|
162
|
+
select: string[];
|
|
171
163
|
} & {
|
|
172
|
-
args?: ((Record<string, unknown> | undefined) & (TAdditionalInput extends import("zod").ZodObject<Record<string, import("zod").
|
|
164
|
+
args?: ((Record<string, unknown> | undefined) & (TAdditionalInput extends import("zod").ZodObject<Record<string, import("zod").ZodTypeAny<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>, import("zod/v4/core").$strip> ? import("zod").infer<TAdditionalInput> : object)) | undefined;
|
|
173
165
|
};
|
|
174
166
|
skip?: number;
|
|
175
167
|
take: number;
|
|
176
168
|
}) => Promise<TItem[]>;
|
|
177
169
|
}) => QueryProcedure<{
|
|
178
170
|
input: {
|
|
179
|
-
select: string[];
|
|
180
171
|
args?: Record<string, unknown> | undefined;
|
|
172
|
+
select: string[];
|
|
181
173
|
} & {
|
|
182
|
-
args?: ((Record<string, unknown> | undefined) & (TAdditionalInput extends import("zod").ZodObject<Record<string, import("zod").
|
|
174
|
+
args?: ((Record<string, unknown> | undefined) & (TAdditionalInput extends import("zod").ZodObject<Record<string, import("zod").ZodTypeAny<unknown, unknown, import("zod/v4/core").$ZodTypeInternals<unknown, unknown>>>, import("zod/v4/core").$strip> ? import("zod").infer<TAdditionalInput> : object)) | undefined;
|
|
183
175
|
};
|
|
184
176
|
meta: unknown;
|
|
185
177
|
output: ConnectionResult<TNode>;
|
|
186
178
|
}>;
|
|
187
|
-
createPlan: <Item extends AnyRecord = AnyRecord>({
|
|
188
|
-
args,
|
|
189
|
-
ctx,
|
|
190
|
-
select,
|
|
191
|
-
view
|
|
192
|
-
}: SourceInput & {
|
|
179
|
+
createPlan: <Item extends AnyRecord = AnyRecord>({ args, ctx, select, view }: SourceInput & {
|
|
193
180
|
ctx?: Context;
|
|
194
181
|
view: ViewTarget<Item>;
|
|
195
182
|
}) => {
|
|
196
|
-
root: SourcePlanNode<unknown, unknown>;
|
|
197
|
-
source: SourceDefinition<Item, unknown>;
|
|
198
183
|
args: AnyRecord | undefined;
|
|
199
184
|
ctx: Context | undefined;
|
|
200
185
|
resolve: (item: Item) => Promise<AnyRecord>;
|
|
201
186
|
resolveMany: (items: Array<AnyRecord>) => Promise<Array<AnyRecord>>;
|
|
202
187
|
selectedPaths: Set<string>;
|
|
203
188
|
view: DataView<Item>;
|
|
189
|
+
root: SourcePlanNode<unknown, unknown>;
|
|
190
|
+
source: SourceDefinition<Item, unknown>;
|
|
204
191
|
};
|
|
205
192
|
procedures: <Item extends AnyRecord, ById extends boolean | undefined = undefined, List extends boolean | ListConfig | undefined = undefined>(input: ViewProcedureInput<Item, ById, List>) => (ById extends false ? Record<never, never> : {
|
|
206
193
|
byId: ReturnType<ReturnType<Procedure["input"]>["query"]>;
|
|
207
194
|
}) & (List extends false ? Record<never, never> : {
|
|
208
195
|
list: QueryProcedure<{
|
|
209
196
|
input: {
|
|
210
|
-
select: string[];
|
|
211
197
|
args?: Record<string, unknown> | undefined;
|
|
198
|
+
select: string[];
|
|
212
199
|
} & {
|
|
213
200
|
args?: Record<string, unknown> | (Record<string, unknown> & object) | undefined;
|
|
214
201
|
};
|
|
@@ -216,92 +203,30 @@ declare function createPrismaFate<Context, Procedure extends ProcedureLike>({
|
|
|
216
203
|
output: ConnectionResult<unknown>;
|
|
217
204
|
}>;
|
|
218
205
|
});
|
|
219
|
-
resolveById: <Item extends AnyRecord = AnyRecord>({
|
|
220
|
-
ctx,
|
|
221
|
-
extra,
|
|
222
|
-
id,
|
|
223
|
-
input,
|
|
224
|
-
view
|
|
225
|
-
}: {
|
|
206
|
+
resolveById: <Item extends AnyRecord = AnyRecord>({ ctx, extra, id, input, view }: {
|
|
226
207
|
ctx: Context;
|
|
227
208
|
extra?: PrismaQueryExtra;
|
|
228
209
|
id: string;
|
|
229
210
|
input: SourceInput;
|
|
230
211
|
view: ViewTarget<Item>;
|
|
231
212
|
}) => Promise<AnyRecord | null>;
|
|
232
|
-
resolveByIds: <Item extends AnyRecord = AnyRecord>({
|
|
233
|
-
ctx,
|
|
234
|
-
extra,
|
|
235
|
-
ids,
|
|
236
|
-
input,
|
|
237
|
-
view
|
|
238
|
-
}: {
|
|
213
|
+
resolveByIds: <Item extends AnyRecord = AnyRecord>({ ctx, extra, ids, input, view }: {
|
|
239
214
|
ctx: Context;
|
|
240
215
|
extra?: PrismaQueryExtra;
|
|
241
216
|
ids: Array<string>;
|
|
242
217
|
input: SourceInput;
|
|
243
218
|
view: ViewTarget<Item>;
|
|
244
219
|
}) => Promise<AnyRecord[]>;
|
|
245
|
-
resolveConnection: <Item extends AnyRecord = AnyRecord>({
|
|
246
|
-
ctx,
|
|
247
|
-
cursor,
|
|
248
|
-
direction,
|
|
249
|
-
extra,
|
|
250
|
-
input,
|
|
251
|
-
skip,
|
|
252
|
-
take,
|
|
253
|
-
view
|
|
254
|
-
}: {
|
|
220
|
+
resolveConnection: <Item extends AnyRecord = AnyRecord>({ ctx, cursor, direction, extra, input, skip, take, view }: {
|
|
255
221
|
ctx: Context;
|
|
256
222
|
cursor?: string;
|
|
257
|
-
direction:
|
|
223
|
+
direction: 'backward' | 'forward';
|
|
258
224
|
extra?: PrismaQueryExtra;
|
|
259
225
|
input: SourceInput;
|
|
260
226
|
skip?: number;
|
|
261
227
|
take: number;
|
|
262
228
|
view: ViewTarget<Item>;
|
|
263
229
|
}) => Promise<AnyRecord[]>;
|
|
264
|
-
fetchById: <Item extends AnyRecord = AnyRecord>({
|
|
265
|
-
ctx,
|
|
266
|
-
extra,
|
|
267
|
-
id,
|
|
268
|
-
plan
|
|
269
|
-
}: {
|
|
270
|
-
ctx: Context;
|
|
271
|
-
extra?: PrismaQueryExtra;
|
|
272
|
-
id: string;
|
|
273
|
-
plan: SourcePlan<Item, Context>;
|
|
274
|
-
}) => Promise<Item | null>;
|
|
275
|
-
fetchByIds: <Item extends AnyRecord = AnyRecord>({
|
|
276
|
-
ctx,
|
|
277
|
-
extra,
|
|
278
|
-
ids,
|
|
279
|
-
plan
|
|
280
|
-
}: {
|
|
281
|
-
ctx: Context;
|
|
282
|
-
extra?: PrismaQueryExtra;
|
|
283
|
-
ids: Array<string>;
|
|
284
|
-
plan: SourcePlan<Item, Context>;
|
|
285
|
-
}) => Promise<Item[]>;
|
|
286
|
-
fetchConnection: <Item extends AnyRecord = AnyRecord>({
|
|
287
|
-
ctx,
|
|
288
|
-
cursor,
|
|
289
|
-
direction,
|
|
290
|
-
extra,
|
|
291
|
-
plan,
|
|
292
|
-
skip,
|
|
293
|
-
take
|
|
294
|
-
}: {
|
|
295
|
-
ctx: Context;
|
|
296
|
-
cursor?: string;
|
|
297
|
-
direction: "backward" | "forward";
|
|
298
|
-
extra?: PrismaQueryExtra;
|
|
299
|
-
plan: SourcePlan<Item, Context>;
|
|
300
|
-
skip?: number;
|
|
301
|
-
take: number;
|
|
302
|
-
}) => Promise<Item[]>;
|
|
303
|
-
getSource: <Item extends AnyRecord = AnyRecord>(target: SourceTarget<Item>) => SourceDefinition<Item, unknown>;
|
|
304
|
-
registry: SourceRegistry<Context>;
|
|
305
230
|
};
|
|
306
231
|
//#endregion
|
|
307
232
|
export { PrismaDelegate, PrismaQueryExtra, PrismaSourceAdapter, PrismaViewConfig, createPrismaFate, createPrismaSourceAdapter, createPrismaSourceRegistry, prismaConnectionArgs };
|
package/lib/server/prisma.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as isRecord } from "../record-B07VwXd-.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { E as stableStringify, S as isDataView, T as toPrismaSelect, c as resolveSourceConnection, d as createSourceDefinitions, f as createSourcePlan, g as attachComputedState, i as createSourceRegistry, k as withConnection, l as collectDataViewConfigs, o as resolveSourceById, p as getDataViewSourceConfig, s as resolveSourceByIds, t as bindSourceProcedures } from "../sourceRouter-51POBlEE.mjs";
|
|
3
3
|
//#region src/server/prisma.ts
|
|
4
4
|
/**
|
|
5
5
|
* fate's Prisma integration.
|
|
@@ -50,11 +50,6 @@ const inferPrismaRelation = ({ field, kind, source, target }) => {
|
|
|
50
50
|
localKey: source.id
|
|
51
51
|
};
|
|
52
52
|
};
|
|
53
|
-
const stableStringify = (value) => {
|
|
54
|
-
if (Array.isArray(value)) return `[${value.map((entry) => stableStringify(entry)).join(",")}]`;
|
|
55
|
-
if (isRecord(value)) return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => `${JSON.stringify(key)}:${stableStringify(entry)}`).join(",")}}`;
|
|
56
|
-
return JSON.stringify(value);
|
|
57
|
-
};
|
|
58
53
|
const resolveSourceReference = (source) => typeof source === "function" ? source() : source;
|
|
59
54
|
const isSourceDefinition = (target) => "view" in target && "id" in target;
|
|
60
55
|
const toPrismaOrderBy = (orderBy) => orderBy.map((entry) => ({ [entry.field]: entry.direction }));
|
|
@@ -187,7 +182,10 @@ function createPrismaSourceAdapter({ prisma, views }) {
|
|
|
187
182
|
items: await delegate.findMany({
|
|
188
183
|
...extra,
|
|
189
184
|
select: toPrismaSelect(plan),
|
|
190
|
-
where: {
|
|
185
|
+
where: {
|
|
186
|
+
...extra?.where ? { AND: [extra.where] } : {},
|
|
187
|
+
id: { in: ids }
|
|
188
|
+
}
|
|
191
189
|
}),
|
|
192
190
|
plan
|
|
193
191
|
});
|
|
@@ -199,7 +197,10 @@ function createPrismaSourceAdapter({ prisma, views }) {
|
|
|
199
197
|
items: (await Promise.all([delegate.findUnique({
|
|
200
198
|
...extra,
|
|
201
199
|
select: toPrismaSelect(plan),
|
|
202
|
-
where: {
|
|
200
|
+
where: {
|
|
201
|
+
...extra?.where ? { AND: [extra.where] } : {},
|
|
202
|
+
id
|
|
203
|
+
}
|
|
203
204
|
})])).flatMap((item) => item ? [item] : []),
|
|
204
205
|
plan
|
|
205
206
|
}))[0] ?? null;
|
package/lib/server.d.mts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { C as liveGlobalConnectionTopic, S as liveEntityTopic, _ as LiveEventBus, b as createLiveEventBus, c as FateServer, d as NativeFateAPI, f as createFateFetchHandler, g as LiveConnectionSourceEvent, h as LiveConnectionEventType, l as FateServerManifest, m as createHonoFateHandler, p as createFateServer, s as FateRequestError, t as isRecord, u as InferFateAPI, v as LiveEventType, x as liveConnectionTopic, y as LiveSourceEvent } from "./record-
|
|
3
|
-
import { A as DataViewListOptions, B as dataView, C as connectionArgs, D as CountSelection, E as ComputedSelection, F as FieldSelection, H as list$1, I as ViewPlan, L as computed, M as DataViewOrderDirection, N as DataViewResult, O as CountWhere, P as Entity, R as count, S as ConnectionResult, T as ComputedField, U as resolver, V as field, _ as createSourcePlan, a as resolveSourceConnection, b as ConnectionItem, c as SourceConfig, d as SourceOrderField, f as SourcePlan, g as createNestedSourcePlan, h as SourceRelationConfig, i as resolveSourceByIds, j as DataViewOrderBy, l as SourceDefinition, m as SourceRelation, n as refetchSourceById, p as SourcePlanNode, r as resolveSourceById, s as OrderDirection, t as SourceRegistry, u as SourceOrder, v as getNestedSelection, w as withConnection, x as ConnectionPagination, y as hasNestedSelection, z as createResolver } from "./executor-
|
|
1
|
+
import { ot as AnyProcedure, v as AnyRecord$1 } from "./transport-DqjhjLfC.mjs";
|
|
2
|
+
import { C as liveGlobalConnectionTopic, S as liveEntityTopic, _ as LiveEventBus, b as createLiveEventBus, c as FateServer, d as NativeFateAPI, f as createFateFetchHandler, g as LiveConnectionSourceEvent, h as LiveConnectionEventType, l as FateServerManifest, m as createHonoFateHandler, p as createFateServer, s as FateRequestError, t as isRecord, u as InferFateAPI, v as LiveEventType, x as liveConnectionTopic, y as LiveSourceEvent } from "./record-DITM4zb_.mjs";
|
|
3
|
+
import { A as DataViewListOptions, B as dataView, C as connectionArgs, D as CountSelection, E as ComputedSelection, F as FieldSelection, H as list$1, I as ViewPlan, L as computed, M as DataViewOrderDirection, N as DataViewResult, O as CountWhere, P as Entity, R as count, S as ConnectionResult, T as ComputedField, U as resolver, V as field, _ as createSourcePlan, a as resolveSourceConnection, b as ConnectionItem, c as SourceConfig, d as SourceOrderField, f as SourcePlan, g as createNestedSourcePlan, h as SourceRelationConfig, i as resolveSourceByIds, j as DataViewOrderBy, l as SourceDefinition, m as SourceRelation, n as refetchSourceById, p as SourcePlanNode, r as resolveSourceById, s as OrderDirection, t as SourceRegistry, u as SourceOrder, v as getNestedSelection, w as withConnection, x as ConnectionPagination, y as hasNestedSelection, z as createResolver } from "./executor-DoiTBiVv.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
|
|
6
5
|
//#region src/server/input.d.ts
|
|
7
6
|
declare const byIdInput: z.ZodObject<{
|
|
8
7
|
args: z.ZodOptional<z.ZodType<Record<string, unknown>, unknown, z.core.$ZodTypeInternals<Record<string, unknown>, unknown>>>;
|
|
@@ -12,10 +11,6 @@ declare const byIdInput: z.ZodObject<{
|
|
|
12
11
|
//#endregion
|
|
13
12
|
//#region src/server/prismaSelect.d.ts
|
|
14
13
|
type AnyRecord = Record<string, unknown>;
|
|
15
|
-
/**
|
|
16
|
-
* Builds a Prisma `select` object from flattened selection paths and optional
|
|
17
|
-
* scoped args, always including the `id` field.
|
|
18
|
-
*/
|
|
19
14
|
declare function toPrismaSelect<Item extends AnyRecord, Context = unknown>(plan: ViewPlan<Item, Context>): AnyRecord;
|
|
20
15
|
//#endregion
|
|
21
16
|
//#region src/server/queryArgs.d.ts
|
|
@@ -79,14 +74,7 @@ type SourceProcedureResult<ById extends boolean | undefined, List extends boolea
|
|
|
79
74
|
* Use this when a router also has custom mutations or custom queries and you
|
|
80
75
|
* want to spread the generated source procedures into that router.
|
|
81
76
|
*/
|
|
82
|
-
declare function createSourceProcedures<Context, Item extends AnyRecord$1, Procedure extends ProcedureLike, ConnectionProcedure extends ConnectionProcedureLike | undefined = ConnectionProcedureLike | undefined, ById extends boolean | undefined = undefined, List extends boolean | ListConfig | undefined = undefined>({
|
|
83
|
-
byId,
|
|
84
|
-
createConnectionProcedure,
|
|
85
|
-
list,
|
|
86
|
-
procedure,
|
|
87
|
-
registry,
|
|
88
|
-
source
|
|
89
|
-
}: SourceProcedureOptions<Context, Item, Procedure, ConnectionProcedure> & {
|
|
77
|
+
declare function createSourceProcedures<Context, Item extends AnyRecord$1, Procedure extends ProcedureLike, ConnectionProcedure extends ConnectionProcedureLike | undefined = ConnectionProcedureLike | undefined, ById extends boolean | undefined = undefined, List extends boolean | ListConfig | undefined = undefined>({ byId, createConnectionProcedure, list, procedure, registry, source }: SourceProcedureOptions<Context, Item, Procedure, ConnectionProcedure> & {
|
|
90
78
|
byId?: ById;
|
|
91
79
|
list?: List;
|
|
92
80
|
}): SourceProcedureResult<ById, List, Procedure, ConnectionProcedure>;
|
package/lib/server.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { t as isRecord } from "./record-B07VwXd-.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { a as hashArgs, i as filterConnectionArgs } from "./args-CRLIRl_v.mjs";
|
|
3
|
+
import { r as toProtocolError, t as FateRequestError } from "./protocol-DS5sf6sd.mjs";
|
|
4
|
+
import { n as liveEntityTopic, r as liveGlobalConnectionTopic, t as liveConnectionTopic } from "./liveTopics-DuFkDZQm.mjs";
|
|
5
|
+
import { A as getScopedArgs, C as list, D as connectionArgs, O as resolveConnection, S as isDataView, T as toPrismaSelect, _ as computed, a as refetchSourceById, b as dataView, c as resolveSourceConnection, f as createSourcePlan, h as hasNestedSelection, k as withConnection, m as getNestedSelection, n as createSourceProcedures, o as resolveSourceById, r as byIdInput, s as resolveSourceByIds, t as bindSourceProcedures, u as createNestedSourcePlan, v as count, w as resolver, x as field, y as createResolver } from "./sourceRouter-51POBlEE.mjs";
|
|
4
6
|
import { EventEmitter, on } from "node:events";
|
|
5
7
|
//#region src/server/live.ts
|
|
6
8
|
const eventName = (type, id) => `${type}:${String(id)}`;
|
|
@@ -288,9 +290,10 @@ const operationKinds = /* @__PURE__ */ new Set([
|
|
|
288
290
|
"query"
|
|
289
291
|
]);
|
|
290
292
|
const assertProtocolRequest = (value) => {
|
|
291
|
-
if (!isRecord(value) || value.version !== 1 || !Array.isArray(value.operations)) throw new FateRequestError("BAD_REQUEST", "Invalid Fate protocol request.");
|
|
293
|
+
if (!isRecord(value) || value.version !== 1 && value.version !== 2 || !Array.isArray(value.operations)) throw new FateRequestError("BAD_REQUEST", "Invalid Fate protocol request.");
|
|
292
294
|
for (const operation of value.operations) {
|
|
293
295
|
if (!isRecord(operation) || typeof operation.id !== "string" || typeof operation.kind !== "string" || !operationKinds.has(operation.kind) || !isStringArray(operation.select) || "args" in operation && operation.args !== void 0 && !isRecord(operation.args)) throw new FateRequestError("BAD_REQUEST", "Invalid Fate protocol operation.");
|
|
296
|
+
if (operation.mutation !== void 0 && (value.version !== 2 || operation.kind !== "mutation" || !isRecord(operation.mutation) || operation.mutation.replayOnly !== void 0 && operation.mutation.replayOnly !== true || typeof operation.mutation.id !== "string" || !operation.mutation.id || operation.mutation.id.length > 256 || typeof operation.mutation.scope !== "string" || operation.mutation.scope.length > 1024)) throw new FateRequestError("BAD_REQUEST", "Invalid durable mutation metadata.");
|
|
294
297
|
if (operation.kind === "byId" && (typeof operation.type !== "string" || !Array.isArray(operation.ids) || !operation.ids.every(isProtocolId))) throw new FateRequestError("BAD_REQUEST", "Invalid Fate byId operation.");
|
|
295
298
|
if ((operation.kind === "list" || operation.kind === "mutation" || operation.kind === "query") && typeof operation.name !== "string") throw new FateRequestError("BAD_REQUEST", "Invalid Fate named operation.");
|
|
296
299
|
}
|
|
@@ -315,8 +318,7 @@ const assertLiveControlRequest = (value) => {
|
|
|
315
318
|
const sse = (message, eventId) => {
|
|
316
319
|
const lines = [];
|
|
317
320
|
if (eventId) lines.push(`id: ${eventId}`);
|
|
318
|
-
lines.push(`event: ${message.kind}`);
|
|
319
|
-
lines.push(`data: ${JSON.stringify(message)}`);
|
|
321
|
+
lines.push(`event: ${message.kind}`, `data: ${JSON.stringify(message)}`);
|
|
320
322
|
return `${lines.join("\n")}\n\n`;
|
|
321
323
|
};
|
|
322
324
|
const sseComment = (message) => `: ${message}\n\n`;
|
|
@@ -343,28 +345,7 @@ const filterLiveSelection = (source, select, changed) => {
|
|
|
343
345
|
}
|
|
344
346
|
return [...result];
|
|
345
347
|
};
|
|
346
|
-
const
|
|
347
|
-
if (segments.length === 0) return true;
|
|
348
|
-
if (Array.isArray(value)) return value.every((entry) => hasSelectedDataPath(entry, segments));
|
|
349
|
-
if (!isRecord(value)) return false;
|
|
350
|
-
const [field, ...rest] = segments;
|
|
351
|
-
return field in value && hasSelectedDataPath(value[field], rest);
|
|
352
|
-
};
|
|
353
|
-
const canUseLiveEventData = (data, selectedPaths) => {
|
|
354
|
-
if (!isRecord(data)) return false;
|
|
355
|
-
for (const path of selectedPaths) if (!hasSelectedDataPath(data, path.split("."))) return false;
|
|
356
|
-
return true;
|
|
357
|
-
};
|
|
358
|
-
const resolveLiveSourceData = async ({ ctx, data, id, input, registry, source }) => {
|
|
359
|
-
if (data !== void 0) {
|
|
360
|
-
if (data == null) return data;
|
|
361
|
-
const plan = createSourcePlan({
|
|
362
|
-
...input,
|
|
363
|
-
ctx,
|
|
364
|
-
source
|
|
365
|
-
});
|
|
366
|
-
if (canUseLiveEventData(data, plan.selectedPaths)) return await plan.resolve(data);
|
|
367
|
-
}
|
|
348
|
+
const resolveLiveSourceData = async ({ ctx, id, input, registry, source }) => {
|
|
368
349
|
return id == null ? null : await resolveSourceById({
|
|
369
350
|
ctx,
|
|
370
351
|
id: String(id),
|
|
@@ -393,7 +374,7 @@ const liveConnectionPayload = (event, node) => {
|
|
|
393
374
|
}
|
|
394
375
|
};
|
|
395
376
|
const sourceScore = (source) => Object.keys(source.view.fields).length + Object.keys(source.relations ?? {}).length;
|
|
396
|
-
function createFateServer({ context, lists, live, mutations, queries, roots, sources }) {
|
|
377
|
+
function createFateServer({ context, idempotency, lists, live, mutations, queries, roots, sources }) {
|
|
397
378
|
const rootLists = /* @__PURE__ */ new Map();
|
|
398
379
|
const rootQueries = /* @__PURE__ */ new Map();
|
|
399
380
|
const sourcesByType = /* @__PURE__ */ new Map();
|
|
@@ -497,12 +478,21 @@ function createFateServer({ context, lists, live, mutations, queries, roots, sou
|
|
|
497
478
|
}
|
|
498
479
|
const mutation = mutations?.[operation.name];
|
|
499
480
|
if (!mutation) throw new FateRequestError("NOT_FOUND", `No mutation registered for '${operation.name}'.`);
|
|
481
|
+
const resolve = async (context) => mutation.resolve({
|
|
482
|
+
ctx: context,
|
|
483
|
+
input: await parseInput(mutation.input, operation.input),
|
|
484
|
+
select: operation.select
|
|
485
|
+
});
|
|
486
|
+
if (operation.mutation && !idempotency) throw new FateRequestError("BAD_REQUEST", "fate: Configure createFateServer({ idempotency: createMutationIdempotency({ scope, store }) }) to accept persisted mutations. The store must commit mutation effects and receipts in the same database transaction.");
|
|
500
487
|
return {
|
|
501
|
-
data: await
|
|
488
|
+
data: operation.mutation ? await idempotency.execute({
|
|
502
489
|
ctx,
|
|
503
|
-
|
|
490
|
+
identity: operation.mutation,
|
|
491
|
+
input: operation.input,
|
|
492
|
+
name: operation.name,
|
|
493
|
+
resolve,
|
|
504
494
|
select: operation.select
|
|
505
|
-
}),
|
|
495
|
+
}) : await resolve(ctx),
|
|
506
496
|
id: operation.id,
|
|
507
497
|
ok: true
|
|
508
498
|
};
|
|
@@ -591,7 +581,6 @@ function createFateServer({ context, lists, live, mutations, queries, roots, sou
|
|
|
591
581
|
};
|
|
592
582
|
const data = event.type === "delete" ? null : await resolveLiveSourceData({
|
|
593
583
|
ctx: connection.ctx,
|
|
594
|
-
data: event.data,
|
|
595
584
|
id: event.id,
|
|
596
585
|
input,
|
|
597
586
|
registry: sources.registry,
|
|
@@ -609,7 +598,6 @@ function createFateServer({ context, lists, live, mutations, queries, roots, sou
|
|
|
609
598
|
const source = nodeType ? sourcesByType.get(nodeType) : null;
|
|
610
599
|
const node = event.type === "deleteEdge" || event.type === "invalidate" ? null : source ? await resolveLiveSourceData({
|
|
611
600
|
ctx: connection.ctx,
|
|
612
|
-
data: event.node,
|
|
613
601
|
id: event.id,
|
|
614
602
|
input: {
|
|
615
603
|
args: operation.selectionArgs,
|
|
@@ -670,7 +658,6 @@ function createFateServer({ context, lists, live, mutations, queries, roots, sou
|
|
|
670
658
|
};
|
|
671
659
|
const data = event.type === "delete" ? null : await resolveLiveSourceData({
|
|
672
660
|
ctx: connection.ctx,
|
|
673
|
-
data: event.data,
|
|
674
661
|
id: event.id,
|
|
675
662
|
input,
|
|
676
663
|
registry: sources.registry,
|
|
@@ -747,7 +734,6 @@ function createFateServer({ context, lists, live, mutations, queries, roots, sou
|
|
|
747
734
|
const source = nodeType ? sourcesByType.get(nodeType) : null;
|
|
748
735
|
const node = event.type === "deleteEdge" || event.type === "invalidate" ? null : source ? await resolveLiveSourceData({
|
|
749
736
|
ctx: connection.ctx,
|
|
750
|
-
data: event.node,
|
|
751
737
|
id: event.id,
|
|
752
738
|
input: {
|
|
753
739
|
args: operation.selectionArgs,
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
//#region src/sortObjectKeys.ts
|
|
2
|
+
/** Recursively sorts plain-object keys, preserving array order and non-plain values. */
|
|
3
|
+
const sortObjectKeys = (value) => {
|
|
4
|
+
if (Array.isArray(value)) return value.map(sortObjectKeys);
|
|
5
|
+
if (value && typeof value === "object" && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null)) return Object.fromEntries(Object.keys(value).sort().map((key) => [key, sortObjectKeys(value[key])]));
|
|
6
|
+
return value;
|
|
7
|
+
};
|
|
8
|
+
//#endregion
|
|
9
|
+
export { sortObjectKeys as t };
|
|
@@ -217,6 +217,14 @@ function withConnection(procedure) {
|
|
|
217
217
|
};
|
|
218
218
|
}
|
|
219
219
|
//#endregion
|
|
220
|
+
//#region src/server/stableStringify.ts
|
|
221
|
+
/** Serializes values with sorted object keys, including undefined properties. */
|
|
222
|
+
const stableStringify = (value) => {
|
|
223
|
+
if (Array.isArray(value)) return `[${value.map(stableStringify).join(",")}]`;
|
|
224
|
+
if (value && typeof value === "object") return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => `${JSON.stringify(key)}:${stableStringify(entry)}`).join(",")}}`;
|
|
225
|
+
return JSON.stringify(value);
|
|
226
|
+
};
|
|
227
|
+
//#endregion
|
|
220
228
|
//#region src/server/prismaSelect.ts
|
|
221
229
|
const toPrismaOrderBy = (orderBy) => orderBy.map((entry) => ({ [entry.field]: entry.direction }));
|
|
222
230
|
const mergeObject = (target, source) => {
|
|
@@ -229,11 +237,6 @@ const mergeObject = (target, source) => {
|
|
|
229
237
|
target[key] = value;
|
|
230
238
|
}
|
|
231
239
|
};
|
|
232
|
-
const stableStringify = (value) => {
|
|
233
|
-
if (Array.isArray(value)) return `[${value.map((entry) => stableStringify(entry)).join(",")}]`;
|
|
234
|
-
if (value && typeof value === "object") return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => `${JSON.stringify(key)}:${stableStringify(entry)}`).join(",")}}`;
|
|
235
|
-
return JSON.stringify(value);
|
|
236
|
-
};
|
|
237
240
|
const getConflictingCountRelations = (node) => {
|
|
238
241
|
const signaturesByRelation = /* @__PURE__ */ new Map();
|
|
239
242
|
for (const computed of node.computeds.values()) {
|
|
@@ -973,4 +976,4 @@ function bindSourceProcedures(defaults) {
|
|
|
973
976
|
});
|
|
974
977
|
}
|
|
975
978
|
//#endregion
|
|
976
|
-
export { list as C,
|
|
979
|
+
export { getScopedArgs as A, list as C, connectionArgs as D, stableStringify as E, resolveConnection as O, isDataView as S, toPrismaSelect as T, computed as _, refetchSourceById as a, dataView as b, resolveSourceConnection as c, createSourceDefinitions as d, createSourcePlan as f, attachComputedState as g, hasNestedSelection as h, createSourceRegistry as i, withConnection as k, collectDataViewConfigs as l, getNestedSelection as m, createSourceProcedures as n, resolveSourceById as o, getDataViewSourceConfig as p, byIdInput as r, resolveSourceByIds as s, bindSourceProcedures as t, createNestedSourcePlan as u, count as v, resolver as w, field as x, createResolver as y };
|