@nkzw/fate 1.0.3 → 1.1.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 +354 -2
- package/docs/api/classes/FateClient.md +110 -40
- package/docs/api/functions/clientRoot.md +1 -1
- package/docs/api/functions/createClient.md +8 -4
- package/docs/api/functions/createGraphQLTransport.md +21 -0
- package/docs/api/functions/createHTTPTransport.md +1 -1
- package/docs/api/functions/createTRPCTransport.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 +39 -0
- 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 +10 -0
- package/docs/api/interfaces/FateThenable.md +3 -3
- package/docs/api/interfaces/Transport.md +7 -7
- package/docs/api/server/classes/FateRequestError.md +5 -5
- package/docs/api/server/drizzle/functions/createDrizzleFate.md +1 -1
- package/docs/api/server/drizzle/functions/createDrizzleSourceAdapter.md +1 -1
- package/docs/api/server/drizzle/functions/createDrizzleSourceRegistry.md +1 -1
- package/docs/api/server/drizzle/type-aliases/DrizzleManyToManyConfig.md +1 -1
- package/docs/api/server/drizzle/type-aliases/DrizzleManyToManyInput.md +1 -1
- package/docs/api/server/drizzle/type-aliases/DrizzleQueryExtra.md +3 -3
- package/docs/api/server/drizzle/type-aliases/DrizzleSourceAdapter.md +9 -9
- package/docs/api/server/drizzle/type-aliases/DrizzleViewConfig.md +1 -1
- package/docs/api/server/functions/bindSourceProcedures.md +1 -1
- package/docs/api/server/functions/computed.md +1 -1
- package/docs/api/server/functions/count.md +1 -1
- package/docs/api/server/functions/createFateFetchHandler.md +1 -1
- package/docs/api/server/functions/createFateServer.md +1 -1
- package/docs/api/server/functions/createHonoFateHandler.md +1 -1
- package/docs/api/server/functions/createLiveEventBus.md +1 -1
- package/docs/api/server/functions/createNestedSourcePlan.md +1 -1
- package/docs/api/server/functions/createResolver.md +1 -1
- package/docs/api/server/functions/createSourcePlan.md +1 -1
- package/docs/api/server/functions/createSourceProcedures.md +1 -1
- package/docs/api/server/functions/dataView.md +1 -1
- package/docs/api/server/functions/field.md +1 -1
- package/docs/api/server/functions/getNestedSelection.md +1 -1
- package/docs/api/server/functions/getScopedArgs.md +1 -1
- package/docs/api/server/functions/hasNestedSelection.md +1 -1
- package/docs/api/server/functions/list.md +1 -1
- package/docs/api/server/functions/refetchSourceById.md +1 -1
- package/docs/api/server/functions/resolveSourceById.md +1 -1
- package/docs/api/server/functions/resolveSourceByIds.md +1 -1
- package/docs/api/server/functions/resolveSourceConnection.md +1 -1
- package/docs/api/server/functions/resolver.md +1 -1
- package/docs/api/server/functions/toPrismaSelect.md +1 -1
- package/docs/api/server/functions/withConnection.md +1 -1
- package/docs/api/server/prisma/functions/createPrismaFate.md +1 -1
- package/docs/api/server/prisma/functions/createPrismaSourceAdapter.md +1 -1
- package/docs/api/server/prisma/functions/createPrismaSourceRegistry.md +1 -1
- package/docs/api/server/prisma/functions/prismaConnectionArgs.md +1 -1
- package/docs/api/server/prisma/type-aliases/PrismaDelegate.md +4 -4
- package/docs/api/server/prisma/type-aliases/PrismaQueryExtra.md +1 -1
- package/docs/api/server/prisma/type-aliases/PrismaSourceAdapter.md +9 -9
- package/docs/api/server/prisma/type-aliases/PrismaViewConfig.md +1 -1
- package/docs/api/server/type-aliases/ComputedField.md +5 -5
- package/docs/api/server/type-aliases/ComputedSelection.md +1 -1
- package/docs/api/server/type-aliases/ConnectionItem.md +3 -3
- package/docs/api/server/type-aliases/ConnectionPagination.md +5 -5
- package/docs/api/server/type-aliases/ConnectionResult.md +3 -3
- package/docs/api/server/type-aliases/CountSelection.md +4 -4
- package/docs/api/server/type-aliases/CountWhere.md +1 -1
- package/docs/api/server/type-aliases/DataViewListOptions.md +2 -2
- package/docs/api/server/type-aliases/DataViewOrderBy.md +1 -1
- package/docs/api/server/type-aliases/DataViewOrderDirection.md +1 -1
- package/docs/api/server/type-aliases/DataViewResult.md +1 -1
- package/docs/api/server/type-aliases/Entity.md +1 -1
- package/docs/api/server/type-aliases/FateServer.md +5 -5
- package/docs/api/server/type-aliases/FateServerManifest.md +1 -1
- package/docs/api/server/type-aliases/FieldSelection.md +3 -3
- package/docs/api/server/type-aliases/LiveConnectionEventType.md +1 -1
- package/docs/api/server/type-aliases/LiveConnectionSourceEvent.md +1 -1
- package/docs/api/server/type-aliases/LiveEventBus.md +1 -1
- package/docs/api/server/type-aliases/LiveEventType.md +1 -1
- package/docs/api/server/type-aliases/LiveSourceEvent.md +1 -1
- package/docs/api/server/type-aliases/NativeFateAPI.md +4 -4
- package/docs/api/server/type-aliases/OrderDirection.md +1 -1
- package/docs/api/server/type-aliases/SourceConfig.md +6 -6
- package/docs/api/server/type-aliases/SourceDefinition.md +6 -6
- package/docs/api/server/type-aliases/SourceOrder.md +1 -1
- package/docs/api/server/type-aliases/SourceOrderField.md +3 -3
- package/docs/api/server/type-aliases/SourcePlan.md +1 -1
- package/docs/api/server/type-aliases/SourcePlanNode.md +1 -1
- package/docs/api/server/type-aliases/SourceRegistry.md +1 -1
- package/docs/api/server/type-aliases/SourceRelation.md +1 -1
- package/docs/api/server/type-aliases/SourceRelationConfig.md +1 -1
- package/docs/api/server/variables/byIdInput.md +1 -1
- package/docs/api/server/variables/connectionArgs.md +1 -1
- package/docs/api/type-aliases/ConnectionMetadata.md +1 -1
- package/docs/api/type-aliases/ConnectionRef.md +1 -1
- package/docs/api/type-aliases/Entity.md +2 -2
- package/docs/api/type-aliases/EntityId.md +1 -1
- package/docs/api/type-aliases/FateDehydratedState.md +11 -0
- 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 +19 -0
- package/docs/api/type-aliases/GraphQLMutationInput.md +11 -0
- package/docs/api/type-aliases/GraphQLMutationMap.md +11 -0
- package/docs/api/type-aliases/GraphQLMutationOutput.md +11 -0
- package/docs/api/type-aliases/GraphQLTransportOptions.md +119 -0
- package/docs/api/type-aliases/HydrateOptions.md +7 -0
- package/docs/api/type-aliases/HydrationLimits.md +7 -0
- package/docs/api/type-aliases/InferFateAPI.md +1 -1
- package/docs/api/type-aliases/List.md +1 -1
- package/docs/api/type-aliases/ListEntry.md +1 -1
- package/docs/api/type-aliases/ListItem.md +1 -1
- package/docs/api/type-aliases/Mask.md +1 -1
- package/docs/api/type-aliases/MutationDefinition.md +1 -1
- package/docs/api/type-aliases/MutationEntity.md +1 -1
- package/docs/api/type-aliases/MutationIdentifier.md +1 -1
- package/docs/api/type-aliases/MutationInput.md +1 -1
- package/docs/api/type-aliases/MutationResult.md +1 -1
- package/docs/api/type-aliases/NodesItem.md +1 -1
- package/docs/api/type-aliases/Pagination.md +5 -5
- package/docs/api/type-aliases/Request.md +1 -1
- package/docs/api/type-aliases/RequestMode.md +1 -1
- package/docs/api/type-aliases/RequestOptions.md +1 -1
- package/docs/api/type-aliases/RequestResult.md +1 -1
- package/docs/api/type-aliases/Selection.md +1 -1
- package/docs/api/type-aliases/Snapshot.md +1 -1
- package/docs/api/type-aliases/TypeConfig.md +4 -4
- package/docs/api/type-aliases/View.md +1 -1
- package/docs/api/type-aliases/ViewData.md +1 -1
- package/docs/api/type-aliases/ViewEntity.md +1 -1
- package/docs/api/type-aliases/ViewEntityName.md +1 -1
- package/docs/api/type-aliases/ViewRef.md +1 -1
- package/docs/api/type-aliases/ViewSelection.md +1 -1
- package/docs/api/type-aliases/ViewSnapshot.md +1 -1
- package/docs/api/type-aliases/ViewTag.md +1 -1
- package/docs/api/variables/ConnectionTag.md +1 -1
- package/docs/guide/getting-started.md +1 -1
- package/docs/guide/graphql-integration.md +298 -0
- package/docs/guide/requests.md +52 -0
- package/docs/guide/server-integration.md +2 -1
- package/lib/{executor-BqwHdN3n.d.mts → executor-sLcAqDMs.d.mts} +1 -1
- package/lib/graphqlTransport-DbRHbYtb.d.mts +74 -0
- package/lib/graphqlTransport-IFgmY-Qq.mjs +499 -0
- package/lib/graphqlTransport.d.mts +2 -0
- package/lib/graphqlTransport.mjs +2 -0
- package/lib/index.d.mts +5 -4
- package/lib/index.mjs +501 -89
- package/lib/{list-4wRNSVgI.d.mts → list-CMQOQGdn.d.mts} +1 -1
- package/lib/list.d.mts +1 -1
- package/lib/list.mjs +1 -1
- package/lib/{liveTopics-DzNtJaBD.mjs → liveTopics-JIDh3t3P.mjs} +1 -1
- package/lib/{record-CirbfZWX.d.mts → record-BtdKzEGI.d.mts} +2 -2
- package/lib/server/drizzle.d.mts +6 -8
- package/lib/server/drizzle.mjs +2 -2
- package/lib/server/prisma.d.mts +6 -8
- package/lib/server/prisma.mjs +2 -2
- package/lib/server.d.mts +3 -3
- package/lib/server.mjs +3 -3
- package/lib/{sourceRouter-C22uFcZg.mjs → sourceRouter-N9Vp0Cj6.mjs} +1 -1
- package/lib/{types-Dz46PXr3.d.mts → transport-BTgtSwOM.d.mts} +211 -143
- package/lib/vite.d.mts +1 -1
- package/lib/vite.mjs +150 -3
- package/package.json +11 -3
- /package/lib/{list-C_mi6GnE.mjs → list-_6fXYLtJ.mjs} +0 -0
- /package/lib/{record-AeZJC9fd.mjs → record-B07VwXd-.mjs} +0 -0
package/lib/vite.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Plugin } from "vite";
|
|
2
2
|
|
|
3
3
|
//#region src/viteTypes.d.ts
|
|
4
|
-
type FateViteTransport = 'native' | 'trpc' | 'void';
|
|
4
|
+
type FateViteTransport = 'graphql' | 'native' | 'trpc' | 'void';
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/vite.d.ts
|
|
7
7
|
type ClientRuntime = '@nkzw/fate' | 'react-fate';
|
package/lib/vite.mjs
CHANGED
|
@@ -68,7 +68,23 @@ const formatTypes = (types) => {
|
|
|
68
68
|
return lines.join("\n");
|
|
69
69
|
};
|
|
70
70
|
const indentBlock = (value, spaces) => value.split("\n").map((line) => line.length ? `${" ".repeat(spaces)}${line}` : line).join("\n");
|
|
71
|
+
const compareStrings = (left, right) => left < right ? -1 : left > right ? 1 : 0;
|
|
72
|
+
const canonicalizeHydrationScopeValue = (value) => {
|
|
73
|
+
if (Array.isArray(value)) return value.map(canonicalizeHydrationScopeValue);
|
|
74
|
+
if (!value || typeof value !== "object") return value;
|
|
75
|
+
return Object.fromEntries(Object.entries(value).sort(([left], [right]) => compareStrings(left, right)).map(([key, entry]) => [key, canonicalizeHydrationScopeValue(entry)]));
|
|
76
|
+
};
|
|
77
|
+
const getHydrationScope = (moduleName, roots, types) => JSON.stringify(canonicalizeHydrationScopeValue({
|
|
78
|
+
moduleName,
|
|
79
|
+
roots,
|
|
80
|
+
types: [...types].sort((left, right) => compareStrings(left.type, right.type))
|
|
81
|
+
}));
|
|
71
82
|
const createClientSource = ({ clientModule = "react-fate", moduleExports, moduleName, runtimeModuleName = moduleName, transport = "trpc" }) => {
|
|
83
|
+
if (transport === "graphql") return createGraphQLClientSource({
|
|
84
|
+
clientModule,
|
|
85
|
+
moduleExports,
|
|
86
|
+
moduleName
|
|
87
|
+
});
|
|
72
88
|
if (transport === "native" || transport === "void") return createNativeClientSource({
|
|
73
89
|
clientModule,
|
|
74
90
|
moduleExports,
|
|
@@ -232,6 +248,7 @@ ${rootsBlock}
|
|
|
232
248
|
|
|
233
249
|
export type GeneratedClientMutations = typeof mutations;
|
|
234
250
|
export type GeneratedClientRoots = typeof roots;
|
|
251
|
+
const hydrationScope = ${JSON.stringify(getHydrationScope(moduleName, roots, types))} as const;
|
|
235
252
|
|
|
236
253
|
export const createFateClient = (options: {
|
|
237
254
|
links: Parameters<typeof createTRPCProxyClient>[0]['links'];
|
|
@@ -254,7 +271,8 @@ ${queriesBlock}${listsBlock} mutations: trpcMutations,
|
|
|
254
271
|
});
|
|
255
272
|
${liveTransportAssignment}
|
|
256
273
|
|
|
257
|
-
return createClient<[GeneratedClientRoots, GeneratedClientMutations]>({
|
|
274
|
+
return createClient<[GeneratedClientRoots, GeneratedClientMutations], typeof hydrationScope>({
|
|
275
|
+
hydrationScope,
|
|
258
276
|
mutations,
|
|
259
277
|
onLiveError: options.onLiveError,
|
|
260
278
|
roots,
|
|
@@ -268,6 +286,132 @@ ${generatedClientTypes}
|
|
|
268
286
|
`;
|
|
269
287
|
};
|
|
270
288
|
const lowerTypeName = (type) => type[0]?.toLowerCase() + type.slice(1);
|
|
289
|
+
const graphQLConfigExportName = "fateGraphQL";
|
|
290
|
+
const formatGraphQLObject = (value, depth = 0) => {
|
|
291
|
+
const indent = " ".repeat(depth);
|
|
292
|
+
const nextIndent = " ".repeat(depth + 1);
|
|
293
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
294
|
+
if (Array.isArray(value)) return `[${value.map((entry) => formatGraphQLObject(entry, depth)).join(", ")}]`;
|
|
295
|
+
const entries = Object.entries(value).filter(([, entry]) => entry !== void 0);
|
|
296
|
+
if (entries.length === 0) return "{}";
|
|
297
|
+
return `{\n${entries.map(([key, entry]) => `${nextIndent}${JSON.stringify(key)}: ${formatGraphQLObject(entry, depth + 1)},`).join("\n")}\n${indent}}`;
|
|
298
|
+
};
|
|
299
|
+
const createGraphQLClientSource = ({ clientModule, moduleExports, moduleName }) => {
|
|
300
|
+
const { Root } = moduleExports;
|
|
301
|
+
const { roots, types } = createSchema(Object.values(moduleExports).filter(isDataView), Root ?? {});
|
|
302
|
+
const graphQLConfig = moduleExports[graphQLConfigExportName] ?? {};
|
|
303
|
+
const byIdEntries = types.map((entry) => ({
|
|
304
|
+
name: lowerTypeName(entry.type),
|
|
305
|
+
type: entry.type
|
|
306
|
+
}));
|
|
307
|
+
const mutationEntries = Object.entries(graphQLConfig.mutations ?? {}).map(([name, config]) => ({
|
|
308
|
+
entity: config.entity,
|
|
309
|
+
field: config.field,
|
|
310
|
+
inputArg: config.inputArg,
|
|
311
|
+
name
|
|
312
|
+
}));
|
|
313
|
+
const rootEntries = [...byIdEntries.map(({ name, type }) => ({
|
|
314
|
+
name,
|
|
315
|
+
type,
|
|
316
|
+
value: `'${name}': clientRoot<Array<${type}>, '${type}'>('${type}'),`
|
|
317
|
+
})), ...Object.entries(roots).map(([name, root]) => ({
|
|
318
|
+
name,
|
|
319
|
+
type: root.type,
|
|
320
|
+
value: `'${name}': clientRoot<${root.kind === "list" ? `{
|
|
321
|
+
items: Array<{ cursor?: string; node: ${root.type} }>;
|
|
322
|
+
pagination: import('${clientModule}').Pagination;
|
|
323
|
+
}` : `${root.type} | null`}, '${root.type}'>('${root.type}'),`
|
|
324
|
+
}))].sort((a, b) => a.name.localeCompare(b.name));
|
|
325
|
+
const importedTypes = Array.from(new Set([
|
|
326
|
+
...types.map((type) => type.type),
|
|
327
|
+
...mutationEntries.map((entry) => entry.entity),
|
|
328
|
+
...graphQLConfig.mutations ? [graphQLConfigExportName] : []
|
|
329
|
+
])).sort((a, b) => a.localeCompare(b));
|
|
330
|
+
const mutationConfigLines = mutationEntries.map(({ entity, name }) => `'${name}': mutation<
|
|
331
|
+
${entity},
|
|
332
|
+
GraphQLMutationInput<typeof ${graphQLConfigExportName}.mutations['${name}']>,
|
|
333
|
+
GraphQLMutationOutput<typeof ${graphQLConfigExportName}.mutations['${name}']>
|
|
334
|
+
>('${entity}'),`);
|
|
335
|
+
const graphQLRoots = Object.fromEntries(Object.entries(roots).map(([name, root]) => [name, {
|
|
336
|
+
connection: root.kind === "list" ? "relay" : void 0,
|
|
337
|
+
field: graphQLConfig.roots?.[name]?.field,
|
|
338
|
+
type: root.type
|
|
339
|
+
}]));
|
|
340
|
+
const graphQLRuntimeConfig = {
|
|
341
|
+
mutations: Object.fromEntries(mutationEntries.map(({ entity, field, inputArg, name }) => [name, {
|
|
342
|
+
entity,
|
|
343
|
+
field,
|
|
344
|
+
...inputArg !== void 0 ? { inputArg } : null
|
|
345
|
+
}])),
|
|
346
|
+
roots: graphQLRoots
|
|
347
|
+
};
|
|
348
|
+
const typesBlock = indentBlock(formatTypes(types), 6);
|
|
349
|
+
const rootBlock = indentBlock(rootEntries.map((entry) => entry.value).join("\n"), 2);
|
|
350
|
+
const mutationConfigBlock = indentBlock(mutationConfigLines.join("\n"), 2);
|
|
351
|
+
const generatedClientTypes = `
|
|
352
|
+
declare module '${`${clientModule}/client`}' {
|
|
353
|
+
interface ClientMutations extends GeneratedClientMutations {}
|
|
354
|
+
interface ClientRoots extends GeneratedClientRoots {}
|
|
355
|
+
|
|
356
|
+
export function createFateClient(
|
|
357
|
+
...args: Parameters<GeneratedCreateFateClient>
|
|
358
|
+
): ReturnType<GeneratedCreateFateClient>;
|
|
359
|
+
}
|
|
360
|
+
`;
|
|
361
|
+
const mutationMapType = graphQLConfig.mutations ? `GraphQLMutationMap<typeof ${graphQLConfigExportName}.mutations>` : "Record<never, never>";
|
|
362
|
+
return `// @generated by @nkzw/fate/vite
|
|
363
|
+
${importedTypes.length ? `import type { ${importedTypes.join(", ")} } from '${moduleName}';\n` : ""}import { clientRoot, createClient, createGraphQLTransport, mutation, type GraphQLMutationInput, type GraphQLMutationMap, type GraphQLMutationOutput } from '${clientModule}';
|
|
364
|
+
|
|
365
|
+
type GraphQLTransportMutations = ${mutationMapType};
|
|
366
|
+
|
|
367
|
+
const graphQL = ${formatGraphQLObject(graphQLRuntimeConfig)} as const;
|
|
368
|
+
|
|
369
|
+
const mutations = {
|
|
370
|
+
${mutationConfigBlock}
|
|
371
|
+
} as const;
|
|
372
|
+
|
|
373
|
+
const roots = {
|
|
374
|
+
${rootBlock}
|
|
375
|
+
} as const;
|
|
376
|
+
|
|
377
|
+
export type GeneratedClientMutations = typeof mutations;
|
|
378
|
+
export type GeneratedClientRoots = typeof roots;
|
|
379
|
+
const hydrationScope = ${JSON.stringify(getHydrationScope(moduleName, roots, types))} as const;
|
|
380
|
+
|
|
381
|
+
export const createFateClient = (options: {
|
|
382
|
+
decodeNodeId?: (type: string, id: string | number) => string | number;
|
|
383
|
+
encodeNodeId?: (type: string, id: string | number) => string | number;
|
|
384
|
+
eventSource?: Parameters<typeof createGraphQLTransport>[0]['eventSource'];
|
|
385
|
+
fetch?: typeof fetch;
|
|
386
|
+
headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
|
|
387
|
+
live?: Parameters<typeof createGraphQLTransport>[0]['live'];
|
|
388
|
+
onLiveError?: (error: unknown) => void;
|
|
389
|
+
url: string | URL;
|
|
390
|
+
}) =>
|
|
391
|
+
createClient<[GeneratedClientRoots, GeneratedClientMutations], typeof hydrationScope>({
|
|
392
|
+
hydrationScope,
|
|
393
|
+
mutations,
|
|
394
|
+
onLiveError: options.onLiveError,
|
|
395
|
+
roots,
|
|
396
|
+
transport: createGraphQLTransport<GraphQLTransportMutations>({
|
|
397
|
+
decodeNodeId: options.decodeNodeId,
|
|
398
|
+
encodeNodeId: options.encodeNodeId,
|
|
399
|
+
eventSource: options.eventSource,
|
|
400
|
+
fetch: options.fetch,
|
|
401
|
+
headers: options.headers,
|
|
402
|
+
live: options.live,
|
|
403
|
+
mutations: graphQL.mutations,
|
|
404
|
+
roots: graphQL.roots,
|
|
405
|
+
types: ${typesBlock.trimStart()},
|
|
406
|
+
url: options.url,
|
|
407
|
+
}),
|
|
408
|
+
types: ${typesBlock.trimStart()},
|
|
409
|
+
});
|
|
410
|
+
|
|
411
|
+
type GeneratedCreateFateClient = typeof createFateClient;
|
|
412
|
+
${generatedClientTypes}
|
|
413
|
+
`;
|
|
414
|
+
};
|
|
271
415
|
const createNativeClientSource = ({ clientModule, moduleExports, moduleName, runtimeModuleName, voidTransport }) => {
|
|
272
416
|
const { Root } = moduleExports;
|
|
273
417
|
const fateExportName = moduleExports.fate?.manifest ? "fate" : moduleExports.fateServer?.manifest ? "fateServer" : null;
|
|
@@ -388,7 +532,8 @@ const createVoidFetch = (options: {
|
|
|
388
532
|
const clientSetup = voidTransport ? ` => {
|
|
389
533
|
const origin = options.origin ?? getDefaultOrigin();
|
|
390
534
|
|
|
391
|
-
return createClient<[GeneratedClientRoots, GeneratedClientMutations]>({
|
|
535
|
+
return createClient<[GeneratedClientRoots, GeneratedClientMutations], typeof hydrationScope>({
|
|
536
|
+
hydrationScope,
|
|
392
537
|
mutations,
|
|
393
538
|
onLiveError: options.onLiveError,
|
|
394
539
|
roots,
|
|
@@ -407,7 +552,8 @@ const createVoidFetch = (options: {
|
|
|
407
552
|
types: ${typesBlock.trimStart()},
|
|
408
553
|
});
|
|
409
554
|
}` : ` =>
|
|
410
|
-
createClient<[GeneratedClientRoots, GeneratedClientMutations]>({
|
|
555
|
+
createClient<[GeneratedClientRoots, GeneratedClientMutations], typeof hydrationScope>({
|
|
556
|
+
hydrationScope,
|
|
411
557
|
mutations,
|
|
412
558
|
onLiveError: options.onLiveError,
|
|
413
559
|
roots,
|
|
@@ -448,6 +594,7 @@ ${rootBlock}
|
|
|
448
594
|
|
|
449
595
|
export type GeneratedClientMutations = typeof mutations;
|
|
450
596
|
export type GeneratedClientRoots = typeof roots;
|
|
597
|
+
const hydrationScope = ${JSON.stringify(getHydrationScope(moduleName, roots, types))} as const;
|
|
451
598
|
|
|
452
599
|
export const createFateClient = (${createClientOptions})${clientSetup};
|
|
453
600
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nkzw/fate",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "fate is a modern data client for React.",
|
|
5
5
|
"homepage": "https://github.com/nkzw-tech/fate",
|
|
6
6
|
"license": "MIT",
|
|
@@ -72,22 +72,30 @@
|
|
|
72
72
|
"@trpc/client": "^11.17.0",
|
|
73
73
|
"@trpc/server": "^11.17.0",
|
|
74
74
|
"drizzle-orm": "^0.45.2",
|
|
75
|
-
"vite": "^8.0.
|
|
75
|
+
"vite": "^8.0.16"
|
|
76
76
|
},
|
|
77
77
|
"peerDependencies": {
|
|
78
78
|
"@trpc/client": "^11.6.0",
|
|
79
79
|
"drizzle-orm": "^0.45.0",
|
|
80
|
+
"graphql": "^16.0.0",
|
|
81
|
+
"graphql-sse": "^2.6.0",
|
|
80
82
|
"vite": "^6.0.0 || ^7.0.0 || ^8.0.0"
|
|
81
83
|
},
|
|
82
84
|
"peerDependenciesMeta": {
|
|
83
85
|
"drizzle-orm": {
|
|
84
86
|
"optional": true
|
|
85
87
|
},
|
|
88
|
+
"graphql": {
|
|
89
|
+
"optional": true
|
|
90
|
+
},
|
|
91
|
+
"graphql-sse": {
|
|
92
|
+
"optional": true
|
|
93
|
+
},
|
|
86
94
|
"vite": {
|
|
87
95
|
"optional": true
|
|
88
96
|
}
|
|
89
97
|
},
|
|
90
98
|
"scripts": {
|
|
91
|
-
"build": "vp pack -d lib --target=node24 src/index.ts src/clientStub.ts src/list.ts src/cli.ts src/server.ts src/server/drizzle.ts src/server/prisma.ts src/vite.ts"
|
|
99
|
+
"build": "vp pack -d lib --target=node24 src/index.ts src/clientStub.ts src/list.ts src/cli.ts src/server.ts src/server/drizzle.ts src/server/prisma.ts src/graphqlTransport.ts src/vite.ts"
|
|
92
100
|
}
|
|
93
101
|
}
|
|
File without changes
|
|
File without changes
|