@nkzw/fate 1.1.0 → 1.3.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 +745 -24
- package/docs/api/classes/FateClient.md +63 -39
- 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 +21 -0
- package/docs/api/functions/getDeferredMetadata.md +21 -0
- 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 +15 -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 +9 -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/Deferred.md +19 -0
- package/docs/api/type-aliases/DeferredMetadata.md +7 -0
- package/docs/api/type-aliases/DeferredSelection.md +13 -0
- package/docs/api/type-aliases/DeferredSnapshot.md +11 -0
- package/docs/api/type-aliases/Entity.md +2 -2
- package/docs/api/type-aliases/EntityId.md +1 -1
- package/docs/api/type-aliases/FateDehydratedState.md +1 -1
- package/docs/api/type-aliases/FateLiveConnectionEvent.md +1 -1
- package/docs/api/type-aliases/FateLiveEvent.md +1 -1
- package/docs/api/type-aliases/FateMutations.md +1 -1
- package/docs/api/type-aliases/FateOperation.md +1 -1
- package/docs/api/type-aliases/FateProtocolRequest.md +1 -1
- package/docs/api/type-aliases/FateProtocolResponse.md +1 -1
- package/docs/api/type-aliases/FateRecord.md +1 -1
- package/docs/api/type-aliases/FateRoots.md +1 -1
- package/docs/api/type-aliases/GraphQLMutationDefinition.md +1 -1
- package/docs/api/type-aliases/GraphQLMutationInput.md +1 -1
- package/docs/api/type-aliases/GraphQLMutationMap.md +1 -1
- package/docs/api/type-aliases/GraphQLMutationOutput.md +1 -1
- package/docs/api/type-aliases/GraphQLTransportOptions.md +11 -11
- package/docs/api/type-aliases/HydrateOptions.md +1 -1
- package/docs/api/type-aliases/HydrationLimits.md +1 -1
- package/docs/api/type-aliases/InferFateAPI.md +1 -1
- package/docs/api/type-aliases/List.md +1 -1
- package/docs/api/type-aliases/ListEntry.md +1 -1
- package/docs/api/type-aliases/ListItem.md +1 -1
- package/docs/api/type-aliases/Mask.md +1 -1
- package/docs/api/type-aliases/MutationDefinition.md +1 -1
- package/docs/api/type-aliases/MutationEntity.md +1 -1
- package/docs/api/type-aliases/MutationIdentifier.md +1 -1
- package/docs/api/type-aliases/MutationInput.md +1 -1
- package/docs/api/type-aliases/MutationResult.md +1 -1
- package/docs/api/type-aliases/NodesItem.md +1 -1
- package/docs/api/type-aliases/Pagination.md +5 -5
- package/docs/api/type-aliases/Request.md +1 -1
- package/docs/api/type-aliases/RequestMode.md +1 -1
- package/docs/api/type-aliases/RequestOptions.md +1 -1
- package/docs/api/type-aliases/RequestResult.md +1 -1
- package/docs/api/type-aliases/Selection.md +1 -1
- package/docs/api/type-aliases/Snapshot.md +1 -1
- package/docs/api/type-aliases/TypeConfig.md +4 -4
- package/docs/api/type-aliases/View.md +1 -1
- package/docs/api/type-aliases/ViewData.md +1 -1
- package/docs/api/type-aliases/ViewEntity.md +1 -1
- package/docs/api/type-aliases/ViewEntityName.md +1 -1
- package/docs/api/type-aliases/ViewRef.md +1 -1
- package/docs/api/type-aliases/ViewSelection.md +1 -1
- package/docs/api/type-aliases/ViewSnapshot.md +1 -1
- package/docs/api/type-aliases/ViewTag.md +1 -1
- package/docs/api/variables/ConnectionTag.md +1 -1
- package/docs/api/variables/DeferTag.md +7 -0
- package/docs/api/variables/DeferredTag.md +7 -0
- package/docs/guide/actions.md +7 -7
- package/docs/guide/deferred-views.md +62 -0
- package/docs/guide/getting-started.md +21 -3
- package/docs/guide/vue.md +256 -0
- package/docs/index.md +1 -0
- package/docs/integrations/cloudflare.md +143 -0
- package/docs/{guide/graphql-integration.md → integrations/graphql.md} +53 -6
- package/docs/{guide/server-integration.md → integrations/server.md} +93 -7
- package/docs/{guide/void-integration.md → integrations/void.md} +94 -12
- package/lib/{executor-sLcAqDMs.d.mts → executor-Dh-MLUXc.d.mts} +1 -1
- package/lib/{graphqlTransport-DbRHbYtb.d.mts → graphqlTransport-B3cbhvJX.d.mts} +1 -1
- package/lib/graphqlTransport.d.mts +1 -1
- package/lib/index.d.mts +10 -5
- package/lib/index.mjs +119 -3
- package/lib/{list-CMQOQGdn.d.mts → list-BrL6PD_6.d.mts} +1 -1
- package/lib/list.d.mts +1 -1
- package/lib/{record-BtdKzEGI.d.mts → record-BkvZwvFk.d.mts} +2 -2
- 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/{transport-BTgtSwOM.d.mts → transport-BjGm__3t.d.mts} +36 -3
- package/lib/vite.d.mts +2 -2
- package/lib/vite.mjs +27 -7
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -78,6 +78,10 @@ const ViewsTag = Symbol("__fate__views");
|
|
|
78
78
|
const NodeRefTag = Symbol("__fate__node-ref");
|
|
79
79
|
/** Symbol attached to connection results so pagination helpers can find their metadata. */
|
|
80
80
|
const ConnectionTag = Symbol("__fate__connection");
|
|
81
|
+
/** Symbol used to mark a selection as deferred. */
|
|
82
|
+
const DeferTag = Symbol("__fate__defer");
|
|
83
|
+
/** Symbol attached to deferred values returned from masked views. */
|
|
84
|
+
const DeferredTag = Symbol("__fate__deferred");
|
|
81
85
|
const viewTag = "__fate-view__";
|
|
82
86
|
/** Generates a stable view tag for a view definition. */
|
|
83
87
|
function getViewTag(id) {
|
|
@@ -104,6 +108,16 @@ const RootKind = "__fate__root";
|
|
|
104
108
|
/** Brand used on mutation definitions to mark their identity in the d.ts output. */
|
|
105
109
|
const MutationKind = "__fate__mutation";
|
|
106
110
|
//#endregion
|
|
111
|
+
//#region src/defer.ts
|
|
112
|
+
function defer(selection) {
|
|
113
|
+
return Object.freeze({ [DeferTag]: selection });
|
|
114
|
+
}
|
|
115
|
+
const isDeferredSelection = (value) => typeof value === "object" && value !== null && DeferTag in value;
|
|
116
|
+
const getDeferredSelection = (selection) => selection[DeferTag];
|
|
117
|
+
const createDeferred = (metadata) => Object.freeze({ [DeferredTag]: metadata });
|
|
118
|
+
const isDeferred = (value) => typeof value === "object" && value !== null && DeferredTag in value;
|
|
119
|
+
const getDeferredMetadata = (deferred) => deferred[DeferredTag];
|
|
120
|
+
//#endregion
|
|
107
121
|
//#region src/node-ref.ts
|
|
108
122
|
function createNodeRef(id) {
|
|
109
123
|
const ref = {};
|
|
@@ -706,6 +720,7 @@ const getSelectionPlan = (viewComposition, ref) => {
|
|
|
706
720
|
if (value) paths.add(path);
|
|
707
721
|
continue;
|
|
708
722
|
}
|
|
723
|
+
if (isDeferredSelection(value)) continue;
|
|
709
724
|
if (isViewTag(key)) {
|
|
710
725
|
if (!ref || ref[ViewsTag] && ref[ViewsTag].has(key)) walk(value.select, prefix);
|
|
711
726
|
continue;
|
|
@@ -743,6 +758,9 @@ const getSelectionPlan = (viewComposition, ref) => {
|
|
|
743
758
|
paths
|
|
744
759
|
};
|
|
745
760
|
};
|
|
761
|
+
const getDeferredSelectionPlan = (field, selection) => {
|
|
762
|
+
return getSelectionPlan({ [field]: selection }, null);
|
|
763
|
+
};
|
|
746
764
|
//#endregion
|
|
747
765
|
//#region src/mutation.ts
|
|
748
766
|
/**
|
|
@@ -1796,6 +1814,7 @@ var FateClient = class {
|
|
|
1796
1814
|
this.parentLists = /* @__PURE__ */ new Map();
|
|
1797
1815
|
this.rootLists = /* @__PURE__ */ new Map();
|
|
1798
1816
|
this.pending = /* @__PURE__ */ new Map();
|
|
1817
|
+
this.pendingDeferred = /* @__PURE__ */ new Map();
|
|
1799
1818
|
this.pendingOptimisticMutations = /* @__PURE__ */ new Map();
|
|
1800
1819
|
this.optimisticMasks = /* @__PURE__ */ new Map();
|
|
1801
1820
|
this.optimisticByEntity = /* @__PURE__ */ new Map();
|
|
@@ -2095,6 +2114,63 @@ var FateClient = class {
|
|
|
2095
2114
|
}
|
|
2096
2115
|
return resolveSnapshot();
|
|
2097
2116
|
}
|
|
2117
|
+
readDeferred(deferred) {
|
|
2118
|
+
const metadata = getDeferredMetadata(deferred);
|
|
2119
|
+
const resolvedOwner = this.optimisticEntityResolutions.get(metadata.owner) ?? metadata.owner;
|
|
2120
|
+
const parsedOwner = parseEntityId(resolvedOwner);
|
|
2121
|
+
const ownerRecord = this.store.read(resolvedOwner);
|
|
2122
|
+
const rawOwnerId = ownerRecord && (typeof ownerRecord.id === "string" || typeof ownerRecord.id === "number") ? ownerRecord.id : parsedOwner.id;
|
|
2123
|
+
const ownerType = parsedOwner.type || metadata.type;
|
|
2124
|
+
const plan = getDeferredSelectionPlan(metadata.field, metadata.selection);
|
|
2125
|
+
const selectedPaths = plan.paths;
|
|
2126
|
+
const missing = this.store.missingForSelection(resolvedOwner, selectedPaths);
|
|
2127
|
+
const hasMissingList = () => this.hasMissingDeferredList(resolvedOwner, ownerType, metadata.field, plan);
|
|
2128
|
+
const listMissing = hasMissingList();
|
|
2129
|
+
const fetchPaths = listMissing ? selectedPaths : missing;
|
|
2130
|
+
const resolveSnapshot = () => {
|
|
2131
|
+
const snapshot = this.readViewSelection({ [metadata.field]: metadata.selection }, this.stableRefWithViewNames(ownerType, rawOwnerId, /* @__PURE__ */ new Set()), resolvedOwner, plan);
|
|
2132
|
+
const resolved = {
|
|
2133
|
+
coverage: snapshot.coverage,
|
|
2134
|
+
data: snapshot.data[metadata.field]
|
|
2135
|
+
};
|
|
2136
|
+
return {
|
|
2137
|
+
status: "fulfilled",
|
|
2138
|
+
then: (onfulfilled, onrejected) => Promise.resolve(resolved).then(onfulfilled, onrejected),
|
|
2139
|
+
value: resolved
|
|
2140
|
+
};
|
|
2141
|
+
};
|
|
2142
|
+
if (missing.size === 0 && !listMissing) {
|
|
2143
|
+
this.clearStalledRequestsForEntity(resolvedOwner);
|
|
2144
|
+
return resolveSnapshot();
|
|
2145
|
+
}
|
|
2146
|
+
const key = this.deferredPendingKey(resolvedOwner, fetchPaths, plan, this.deferredSelectionSignature(metadata.selection));
|
|
2147
|
+
if (this.stalledRequests.has(key)) return resolveSnapshot();
|
|
2148
|
+
const pendingOptimistic = this.getPendingOptimisticMutations(resolvedOwner);
|
|
2149
|
+
if (pendingOptimistic) {
|
|
2150
|
+
const pending = this.pendingDeferred.get(key);
|
|
2151
|
+
if (pending) return pending;
|
|
2152
|
+
const promise = Promise.all(pendingOptimistic).then(() => this.readDeferred(deferred)).finally(() => this.pendingDeferred.delete(key));
|
|
2153
|
+
this.pendingDeferred.set(key, promise);
|
|
2154
|
+
return promise;
|
|
2155
|
+
}
|
|
2156
|
+
const pendingPromise = this.pendingDeferred.get(key) || null;
|
|
2157
|
+
if (pendingPromise) return pendingPromise;
|
|
2158
|
+
const promise = this.trackPendingRequest(async () => {
|
|
2159
|
+
try {
|
|
2160
|
+
await this.fetchByIdAndNormalize(ownerType, [rawOwnerId], fetchPaths, plan);
|
|
2161
|
+
if (this.store.missingForSelection(resolvedOwner, selectedPaths).size > 0 || hasMissingList()) {
|
|
2162
|
+
this.stalledRequests.add(key);
|
|
2163
|
+
return resolveSnapshot().value;
|
|
2164
|
+
}
|
|
2165
|
+
this.stalledRequests.delete(key);
|
|
2166
|
+
return this.readDeferred(deferred).value;
|
|
2167
|
+
} finally {
|
|
2168
|
+
this.pendingDeferred.delete(key);
|
|
2169
|
+
}
|
|
2170
|
+
});
|
|
2171
|
+
this.pendingDeferred.set(key, promise);
|
|
2172
|
+
return promise;
|
|
2173
|
+
}
|
|
2098
2174
|
assertLiveViewSupport() {
|
|
2099
2175
|
if (!this.transport.subscribeById) throw new Error(`fate: transport does not support live views. Please provide a 'subscribeById' implementation in your transport.`);
|
|
2100
2176
|
}
|
|
@@ -3138,8 +3214,20 @@ var FateClient = class {
|
|
|
3138
3214
|
target[ViewsTag].add(key);
|
|
3139
3215
|
continue;
|
|
3140
3216
|
}
|
|
3141
|
-
coverageById.set(parentId, (coverageById.get(parentId) ?? /* @__PURE__ */ new Set()).add(key));
|
|
3142
3217
|
const fieldPath = prefix ? `${prefix}.${key}` : key;
|
|
3218
|
+
if (isDeferredSelection(selectionKind)) {
|
|
3219
|
+
const { id, type } = parseEntityId(parentId);
|
|
3220
|
+
coverageById.set(parentId, (coverageById.get(parentId) ?? /* @__PURE__ */ new Set()).add(key));
|
|
3221
|
+
target[key] = createDeferred({
|
|
3222
|
+
field: key,
|
|
3223
|
+
id,
|
|
3224
|
+
owner: parentId,
|
|
3225
|
+
selection: getDeferredSelection(selectionKind),
|
|
3226
|
+
type
|
|
3227
|
+
});
|
|
3228
|
+
continue;
|
|
3229
|
+
}
|
|
3230
|
+
coverageById.set(parentId, (coverageById.get(parentId) ?? /* @__PURE__ */ new Set()).add(key));
|
|
3143
3231
|
const selectionType = typeof selectionKind;
|
|
3144
3232
|
if (selectionType === "boolean" && selectionKind) target[key] = record[key];
|
|
3145
3233
|
else if (selectionKind && selectionType === "object") {
|
|
@@ -3258,7 +3346,9 @@ var FateClient = class {
|
|
|
3258
3346
|
}
|
|
3259
3347
|
};
|
|
3260
3348
|
const data = { __typename: parseEntityId(entityId).type };
|
|
3261
|
-
|
|
3349
|
+
const payloads = getViewPayloads(viewComposition, ref);
|
|
3350
|
+
if (payloads.length === 0 && isRecord(viewComposition)) walk(viewComposition, record, data, entityId, pathPrefix);
|
|
3351
|
+
else for (const viewPayload of payloads) walk(viewPayload.select, record, data, entityId, pathPrefix);
|
|
3262
3352
|
return {
|
|
3263
3353
|
coverage: [...coverageById.entries()],
|
|
3264
3354
|
data
|
|
@@ -3274,6 +3364,32 @@ var FateClient = class {
|
|
|
3274
3364
|
pendingKey(entityId, missingFields) {
|
|
3275
3365
|
return `${this.pendingPrefix(entityId)}${[...missingFields].sort().join("|")}`;
|
|
3276
3366
|
}
|
|
3367
|
+
deferredPendingKey(entityId, fields, plan, selectionSignature) {
|
|
3368
|
+
const args = [...plan.args.entries()].map(([path, entry]) => `${path}:${entry.hash}`).sort().join("|");
|
|
3369
|
+
return `${this.pendingKey(entityId, new Set(fields))}|${args}|${selectionSignature}`;
|
|
3370
|
+
}
|
|
3371
|
+
deferredSelectionSignature(selection) {
|
|
3372
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3373
|
+
const serialize = (value) => {
|
|
3374
|
+
if (value === null || typeof value !== "object") return `${typeof value}:${String(value)}`;
|
|
3375
|
+
if (seen.has(value)) return "[Circular]";
|
|
3376
|
+
seen.add(value);
|
|
3377
|
+
if (Array.isArray(value)) return `[${value.map((item) => serialize(item)).join(",")}]`;
|
|
3378
|
+
return `{${Object.entries(value).sort(([left], [right]) => left.localeCompare(right)).map(([key, entry]) => isViewTag(key) ? `view:${key}` : `${key}:${serialize(entry)}`).join(",")}}`;
|
|
3379
|
+
};
|
|
3380
|
+
return serialize(selection);
|
|
3381
|
+
}
|
|
3382
|
+
hasMissingDeferredList(owner, type, field, plan) {
|
|
3383
|
+
const descriptor = this.types.get(type)?.fields?.[field];
|
|
3384
|
+
if (!descriptor || descriptor === "scalar" || !("listOf" in descriptor)) return false;
|
|
3385
|
+
const fieldArgs = plan.args.get(field);
|
|
3386
|
+
const listState = this.store.getListState(getListKey(owner, field, fieldArgs?.hash));
|
|
3387
|
+
if (!listState) return true;
|
|
3388
|
+
const args = fieldArgs?.value;
|
|
3389
|
+
const paginationArgs = getPaginationArgsInfo(args);
|
|
3390
|
+
if (paginationArgs.hasCursorArg) return true;
|
|
3391
|
+
return !hasConnectionPageCoverage(listState, args, paginationArgs.direction);
|
|
3392
|
+
}
|
|
3277
3393
|
liveSubscriptionKey(entityId, plan) {
|
|
3278
3394
|
return `${entityId}|${[...plan.paths].sort().join("|")}|${[...plan.args.entries()].map(([path, entry]) => `${path}:${entry.hash}`).sort().join("|")}`;
|
|
3279
3395
|
}
|
|
@@ -3808,4 +3924,4 @@ function clientRoot(type) {
|
|
|
3808
3924
|
});
|
|
3809
3925
|
}
|
|
3810
3926
|
//#endregion
|
|
3811
|
-
export { ConnectionTag, FateClient, clientRoot, createClient, createGraphQLTransport, createHTTPTransport, createTRPCTransport, getListEntries, getSelectionPlan, graphqlMutation, isRecord, isViewTag, liveConnectionTopic, liveEntityTopic, liveGlobalConnectionTopic, mutation, toEntityId, view };
|
|
3927
|
+
export { ConnectionTag, DeferTag, DeferredTag, FateClient, clientRoot, createClient, createGraphQLTransport, createHTTPTransport, createTRPCTransport, defer, getDeferredMetadata, getListEntries, getSelectionPlan, graphqlMutation, isDeferred, isRecord, isViewTag, liveConnectionTopic, liveEntityTopic, liveGlobalConnectionTopic, mutation, toEntityId, view };
|
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-BrL6PD_6.mjs";
|
|
2
2
|
export { ListEntry, getListEntries };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as AnyRecord } from "./transport-
|
|
2
|
-
import { N as DataViewResult, S as ConnectionResult, k as DataView, l as SourceDefinition, t as SourceRegistry } from "./executor-
|
|
1
|
+
import { r as AnyRecord } from "./transport-BjGm__3t.mjs";
|
|
2
|
+
import { N as DataViewResult, S as ConnectionResult, k as DataView, l as SourceDefinition, t as SourceRegistry } from "./executor-Dh-MLUXc.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/liveTopics.d.ts
|
|
5
5
|
declare const liveEntityTopic: (type: string, id: string | number) => string;
|
package/lib/server/drizzle.d.mts
CHANGED
|
@@ -1,5 +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, t as SourceRegistry } from "../executor-
|
|
1
|
+
import { r as AnyRecord, rt as QueryProcedure } from "../transport-BjGm__3t.mjs";
|
|
2
|
+
import { S as ConnectionResult, c as SourceConfig, f as SourcePlan, k as DataView, l as SourceDefinition, o as DataViewModule, p as SourcePlanNode, t as SourceRegistry } from "../executor-Dh-MLUXc.mjs";
|
|
3
3
|
import { AnyColumn, SQLWrapper, Table } from "drizzle-orm";
|
|
4
4
|
|
|
5
5
|
//#region src/server/drizzle.d.ts
|
package/lib/server/prisma.d.mts
CHANGED
|
@@ -1,5 +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-
|
|
1
|
+
import { r as AnyRecord, rt as QueryProcedure } from "../transport-BjGm__3t.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-Dh-MLUXc.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/server/prisma.d.ts
|
|
5
5
|
type PrismaDelegate = {
|
package/lib/server.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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 { nt as AnyProcedure, r as AnyRecord$1 } from "./transport-BjGm__3t.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-BkvZwvFk.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-Dh-MLUXc.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
6
6
|
//#region src/server/input.d.ts
|
|
@@ -741,6 +741,10 @@ type RequestMode = /** (default) Use cached data if present, otherwise fetch. */
|
|
|
741
741
|
type RequestOptions = Readonly<{
|
|
742
742
|
mode?: RequestMode;
|
|
743
743
|
}>;
|
|
744
|
+
type DeferredSnapshot<T> = Readonly<{
|
|
745
|
+
coverage: ReadonlyArray<readonly [id: EntityId, paths: ReadonlySet<string>]>;
|
|
746
|
+
data: T;
|
|
747
|
+
}>;
|
|
744
748
|
type FateClientOptions<Roots extends FateRoots, Mutations extends FateMutations, HydrationScope extends string> = {
|
|
745
749
|
/**
|
|
746
750
|
* Number of recently released requests to keep retained before their records
|
|
@@ -775,6 +779,7 @@ declare class FateClient<Roots extends FateRoots, Mutations extends FateMutation
|
|
|
775
779
|
private readonly parentLists;
|
|
776
780
|
private readonly rootLists;
|
|
777
781
|
private readonly pending;
|
|
782
|
+
private readonly pendingDeferred;
|
|
778
783
|
private readonly pendingOptimisticMutations;
|
|
779
784
|
private readonly optimisticMasks;
|
|
780
785
|
private readonly optimisticByEntity;
|
|
@@ -836,6 +841,7 @@ declare class FateClient<Roots extends FateRoots, Mutations extends FateMutation
|
|
|
836
841
|
[ViewsTag]: Set<string>;
|
|
837
842
|
}>;
|
|
838
843
|
readView<T extends Entity, S extends Selection<T>, V extends View<T, S>>(view: V, ref: ViewRef<T['__typename']>): FateThenable<ViewSnapshot<T, S>>;
|
|
844
|
+
readDeferred<T>(deferred: Deferred<T>): PromiseLike<DeferredSnapshot<T>>;
|
|
839
845
|
assertLiveViewSupport(): void;
|
|
840
846
|
assertLiveConnectionSupport(): void;
|
|
841
847
|
subscribeLiveView<T extends Entity, S extends Selection<T>, V extends View<T, S>>(view: V, ref: ViewRef<T['__typename']>): () => void;
|
|
@@ -926,6 +932,9 @@ declare class FateClient<Roots extends FateRoots, Mutations extends FateMutation
|
|
|
926
932
|
private clearStalledRequestsForEntity;
|
|
927
933
|
private pendingPrefix;
|
|
928
934
|
private pendingKey;
|
|
935
|
+
private deferredPendingKey;
|
|
936
|
+
private deferredSelectionSignature;
|
|
937
|
+
private hasMissingDeferredList;
|
|
929
938
|
private liveSubscriptionKey;
|
|
930
939
|
private liveConnectionSubscriptionKey;
|
|
931
940
|
private releaseLiveSubscription;
|
|
@@ -1004,6 +1013,10 @@ declare const ViewKind: unique symbol;
|
|
|
1004
1013
|
declare const ViewsTag: unique symbol;
|
|
1005
1014
|
/** Symbol attached to connection results so pagination helpers can find their metadata. */
|
|
1006
1015
|
declare const ConnectionTag: unique symbol;
|
|
1016
|
+
/** Symbol used to mark a selection as deferred. */
|
|
1017
|
+
declare const DeferTag: unique symbol;
|
|
1018
|
+
/** Symbol attached to deferred values returned from masked views. */
|
|
1019
|
+
declare const DeferredTag: unique symbol;
|
|
1007
1020
|
declare const __FateEntityBrand: unique symbol;
|
|
1008
1021
|
declare const __FateSelectionBrand: unique symbol;
|
|
1009
1022
|
declare const __FateMutationEntityBrand: unique symbol;
|
|
@@ -1011,6 +1024,7 @@ declare const __FateMutationInputBrand: unique symbol;
|
|
|
1011
1024
|
declare const __FateMutationResultBrand: unique symbol;
|
|
1012
1025
|
declare const __FateRootResultBrand: unique symbol;
|
|
1013
1026
|
declare const __FateRootTypeBrand: unique symbol;
|
|
1027
|
+
declare const __FateDeferredBrand: unique symbol;
|
|
1014
1028
|
type __ViewEntityAnchor<T extends Entity> = {
|
|
1015
1029
|
readonly [__FateEntityBrand]?: T;
|
|
1016
1030
|
};
|
|
@@ -1097,6 +1111,24 @@ type ConnectionRef<TName extends string> = Readonly<{
|
|
|
1097
1111
|
}>;
|
|
1098
1112
|
pagination?: Pagination;
|
|
1099
1113
|
}>;
|
|
1114
|
+
/** Selection wrapper created by `defer(...)`. */
|
|
1115
|
+
type DeferredSelection<S> = Readonly<{
|
|
1116
|
+
[DeferTag]: S;
|
|
1117
|
+
}>;
|
|
1118
|
+
/** Runtime metadata used by the client to resolve a deferred field. */
|
|
1119
|
+
type DeferredMetadata = Readonly<{
|
|
1120
|
+
field: string;
|
|
1121
|
+
id: string | number;
|
|
1122
|
+
owner: EntityId;
|
|
1123
|
+
selection: unknown;
|
|
1124
|
+
type: string;
|
|
1125
|
+
}>;
|
|
1126
|
+
/** A deferred value returned from a masked view. Existing view hooks resolve it when read. */
|
|
1127
|
+
type Deferred<T> = Readonly<{
|
|
1128
|
+
[DeferredTag]: DeferredMetadata;
|
|
1129
|
+
}> & {
|
|
1130
|
+
readonly [__FateDeferredBrand]: T;
|
|
1131
|
+
};
|
|
1100
1132
|
/** Base shape shared by all entities fetched by fate. */
|
|
1101
1133
|
type Entity = {
|
|
1102
1134
|
__typename: string;
|
|
@@ -1120,7 +1152,8 @@ type ConnectionSelectionBase<T extends Entity> = Readonly<{
|
|
|
1120
1152
|
type ConnectionSelection<T extends Entity> = ConnectionSelectionBase<T> | (SelectionArgs & ConnectionSelectionBase<T>);
|
|
1121
1153
|
type BaseSelectionFieldValue<T extends Entity, K extends keyof T> = NonNullable<T[K]> extends Array<infer U extends Entity> ? true | Selection<U> | ConnectionSelection<U> | View<U, Selection<U>> : NonNullable<T[K]> extends Entity ? true | Selection<NonNullable<T[K]>> | View<NonNullable<T[K]>, Selection<NonNullable<T[K]>>> : NonNullable<T[K]> extends AnyRecord ? PlainObjectSelection<NonNullable<T[K]>> : true;
|
|
1122
1154
|
type SelectionFieldValue<T extends Entity, K extends keyof T> = BaseSelectionFieldValue<T, K> | SelectionArgs | (SelectionArgs & Extract<BaseSelectionFieldValue<T, K>, object>);
|
|
1123
|
-
type
|
|
1155
|
+
type DeferrableSelectionFieldValue<T extends Entity, K extends keyof T> = SelectionFieldValue<T, K> | DeferredSelection<SelectionFieldValue<T, K>>;
|
|
1156
|
+
type SelectionShape<T extends Entity> = { [K in keyof T as K extends '__typename' ? never : K]?: DeferrableSelectionFieldValue<T, K> } & {
|
|
1124
1157
|
__typename?: true;
|
|
1125
1158
|
};
|
|
1126
1159
|
type SelectionViewSpread<T extends Entity> = { readonly [K in ViewTag]?: Readonly<{
|
|
@@ -1182,7 +1215,7 @@ type EntityName<T> = T extends {
|
|
|
1182
1215
|
__typename: infer N extends string;
|
|
1183
1216
|
} ? N : never;
|
|
1184
1217
|
/** Recursively applies a view selection to an entity to mask fields that aren't selected. */
|
|
1185
|
-
type MaskNonNullish<T, S> = T extends Array<infer U extends Entity> ? S extends true ? Array<U> : S extends ConnectionLikeSelection ? ConnectionMask<U, S> : HasViewTag<S> extends true ? Array<ViewRef<U['__typename']>> : Array<Mask<U, S>> : S extends true ? T : S extends object ? HasViewTag<S> extends true ? NonNullish<T> extends Entity ? ViewRef<EntityName<NonNullish<T>>> : ViewRef<EntityName<NonNullable<T>>> : { [K in keyof S as K extends 'args' ? never : K]: S[K] extends true ? NonNullish<T>[Extract<K, keyof T>] : Mask<NonNullish<T>[Extract<K, keyof T>], Extract<S[K], object>> } & (T extends Entity ? Pick<NonNullish<T>, '__typename'> : Record<never, never>) : T;
|
|
1218
|
+
type MaskNonNullish<T, S> = T extends Array<infer U extends Entity> ? S extends true ? Array<U> : S extends ConnectionLikeSelection ? ConnectionMask<U, S> : HasViewTag<S> extends true ? Array<ViewRef<U['__typename']>> : Array<Mask<U, S>> : S extends true ? T : S extends object ? HasViewTag<S> extends true ? NonNullish<T> extends Entity ? ViewRef<EntityName<NonNullish<T>>> : ViewRef<EntityName<NonNullable<T>>> : { [K in keyof S as K extends 'args' ? never : K]: S[K] extends true ? NonNullish<T>[Extract<K, keyof T>] : S[K] extends DeferredSelection<infer DeferredSelectionValue> ? Deferred<Mask<NonNullish<T>[Extract<K, keyof T>], DeferredSelectionValue>> : Mask<NonNullish<T>[Extract<K, keyof T>], Extract<S[K], object>> } & (T extends Entity ? Pick<NonNullish<T>, '__typename'> : Record<never, never>) : T;
|
|
1186
1219
|
type Mask<T, S> = WithNullish<T, MaskNonNullish<NonNullish<T>, S>>;
|
|
1187
1220
|
/** Entity type captured from a view definition. */
|
|
1188
1221
|
type ViewEntity<V> = V extends View<infer T, any> ? T : never;
|
|
@@ -1410,4 +1443,4 @@ declare function createTRPCTransport<AppRouter extends AnyRouter, Mutations exte
|
|
|
1410
1443
|
queries?: TRPCQueryResolvers<AppRouter>;
|
|
1411
1444
|
}): Transport<MutationMapFromResolvers<Mutations>>;
|
|
1412
1445
|
//#endregion
|
|
1413
|
-
export {
|
|
1446
|
+
export { HydrateOptions as $, Snapshot as A, ViewTag as B, MutationShape as C, RequestResult as D, Request$1 as E, ViewEntity as F, mutation as G, __FateSelectionBrand as H, ViewEntityName as I, RequestMode as J, DeferredSnapshot as K, ViewRef as L, TypeName as M, View as N, RootDefinition as O, ViewData as P, FateDehydratedState as Q, ViewSelection as R, MutationResult as S, Pagination as T, isViewTag as U, __FateEntityBrand as V, FateMutations as W, createClient as X, RequestOptions as Y, getSelectionPlan as Z, Mask as _, ConnectionRef as a, MutationIdentifier as b, Deferred as c, DeferredTag as d, HydrationLimits as et, Entity as f, ListItem as g, FateThenable as h, ConnectionMetadata as i, TypeConfig as j, Selection as k, DeferredMetadata as l, FateRoots as m, createTRPCTransport as n, AnyProcedure as nt, ConnectionTag as o, EntityId as p, FateClient as q, AnyRecord as r, QueryProcedure as rt, DeferTag as s, Transport as t, List as tt, DeferredSelection as u, MutationDefinition as v, NodesItem as w, MutationInput as x, MutationEntity as y, ViewSnapshot as z };
|
package/lib/vite.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Plugin } from "vite";
|
|
2
2
|
|
|
3
3
|
//#region src/viteTypes.d.ts
|
|
4
|
-
type FateViteTransport = 'graphql' | 'native' | 'trpc' | 'void';
|
|
4
|
+
type FateViteTransport = 'cloudflare' | 'graphql' | 'native' | 'trpc' | 'void';
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region src/vite.d.ts
|
|
7
|
-
type ClientRuntime = '@nkzw/fate' | 'react-fate';
|
|
7
|
+
type ClientRuntime = '@nkzw/fate' | 'react-fate' | 'vue-fate';
|
|
8
8
|
type FateVitePluginOptions = {
|
|
9
9
|
clientModule?: ClientRuntime;
|
|
10
10
|
generatedFile?: false | string;
|
package/lib/vite.mjs
CHANGED
|
@@ -87,11 +87,20 @@ const createClientSource = ({ clientModule = "react-fate", moduleExports, module
|
|
|
87
87
|
});
|
|
88
88
|
if (transport === "native" || transport === "void") return createNativeClientSource({
|
|
89
89
|
clientModule,
|
|
90
|
+
cloudflareTransport: false,
|
|
90
91
|
moduleExports,
|
|
91
92
|
moduleName,
|
|
92
93
|
runtimeModuleName,
|
|
93
94
|
voidTransport: transport === "void"
|
|
94
95
|
});
|
|
96
|
+
if (transport === "cloudflare") return createNativeClientSource({
|
|
97
|
+
clientModule,
|
|
98
|
+
cloudflareTransport: true,
|
|
99
|
+
moduleExports,
|
|
100
|
+
moduleName,
|
|
101
|
+
runtimeModuleName,
|
|
102
|
+
voidTransport: false
|
|
103
|
+
});
|
|
95
104
|
const { appRouter, Root } = moduleExports;
|
|
96
105
|
const { roots, types } = createSchema(Object.values(moduleExports).filter(isDataView), Root ?? {});
|
|
97
106
|
const routerRecord = appRouter._def?.record ?? {};
|
|
@@ -412,7 +421,7 @@ type GeneratedCreateFateClient = typeof createFateClient;
|
|
|
412
421
|
${generatedClientTypes}
|
|
413
422
|
`;
|
|
414
423
|
};
|
|
415
|
-
const createNativeClientSource = ({ clientModule, moduleExports, moduleName, runtimeModuleName, voidTransport }) => {
|
|
424
|
+
const createNativeClientSource = ({ clientModule, cloudflareTransport, moduleExports, moduleName, runtimeModuleName, voidTransport }) => {
|
|
416
425
|
const { Root } = moduleExports;
|
|
417
426
|
const fateExportName = moduleExports.fate?.manifest ? "fate" : moduleExports.fateServer?.manifest ? "fateServer" : null;
|
|
418
427
|
const fateServer = fateExportName ? moduleExports[fateExportName] : null;
|
|
@@ -510,7 +519,17 @@ const createVoidFetch = (options: {
|
|
|
510
519
|
});
|
|
511
520
|
};
|
|
512
521
|
` : "";
|
|
513
|
-
const
|
|
522
|
+
const cloudflareHelpers = cloudflareTransport ? `
|
|
523
|
+
const defaultCloudflareFateRpcPath = '/fate';
|
|
524
|
+
const defaultCloudflareFateLivePath = '/fate-live';
|
|
525
|
+
|
|
526
|
+
const getDefaultOrigin = () =>
|
|
527
|
+
typeof window === 'undefined' ? 'http://localhost' : window.location.origin;
|
|
528
|
+
|
|
529
|
+
const toEndpointUrl = (url: string | URL | undefined, path: string, origin: string | URL) =>
|
|
530
|
+
url ?? new URL(path, origin);
|
|
531
|
+
` : "";
|
|
532
|
+
const createClientOptions = voidTransport || cloudflareTransport ? `options: {
|
|
514
533
|
fetch?: typeof fetch;
|
|
515
534
|
headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
|
|
516
535
|
livePath?: string;
|
|
@@ -529,7 +548,7 @@ const createVoidFetch = (options: {
|
|
|
529
548
|
onLiveError?: (error: unknown) => void;
|
|
530
549
|
url: string | URL;
|
|
531
550
|
}`;
|
|
532
|
-
const clientSetup = voidTransport ? ` => {
|
|
551
|
+
const clientSetup = voidTransport || cloudflareTransport ? ` => {
|
|
533
552
|
const origin = options.origin ?? getDefaultOrigin();
|
|
534
553
|
|
|
535
554
|
return createClient<[GeneratedClientRoots, GeneratedClientMutations], typeof hydrationScope>({
|
|
@@ -538,16 +557,16 @@ const createVoidFetch = (options: {
|
|
|
538
557
|
onLiveError: options.onLiveError,
|
|
539
558
|
roots,
|
|
540
559
|
transport: createHTTPTransport<FateAPI>({
|
|
541
|
-
fetch: createVoidFetch(options),
|
|
560
|
+
fetch: ${voidTransport ? "createVoidFetch(options)" : "options.fetch"},
|
|
542
561
|
headers: options.headers,
|
|
543
|
-
live: ${hasLive ? "connectLiveStream" : "false"},
|
|
562
|
+
live: ${hasLive ? voidTransport ? "connectLiveStream" : "connectCloudflareFateStream" : "false"},
|
|
544
563
|
liveRetryMs: options.liveRetryMs,
|
|
545
564
|
liveUrl: toEndpointUrl(
|
|
546
565
|
options.liveUrl,
|
|
547
|
-
options.livePath ?? defaultVoidFateLivePath,
|
|
566
|
+
options.livePath ?? ${voidTransport ? "defaultVoidFateLivePath" : "defaultCloudflareFateLivePath"},
|
|
548
567
|
origin,
|
|
549
568
|
),
|
|
550
|
-
url: toEndpointUrl(options.url, options.rpcPath ?? defaultVoidFateRpcPath, origin),
|
|
569
|
+
url: toEndpointUrl(options.url, options.rpcPath ?? ${voidTransport ? "defaultVoidFateRpcPath" : "defaultCloudflareFateRpcPath"}, origin),
|
|
551
570
|
}),
|
|
552
571
|
types: ${typesBlock.trimStart()},
|
|
553
572
|
});
|
|
@@ -581,6 +600,7 @@ declare module '${clientDeclarationModule}' {
|
|
|
581
600
|
import type { ${importedTypes.join(", ")} } from '${moduleName}';
|
|
582
601
|
import { clientRoot, createClient, createHTTPTransport, mutation, type InferFateAPI } from '${clientModule}';
|
|
583
602
|
${voidTransport && hasLive ? "import { connectLiveStream } from 'void/live/client';\n" : ""}${voidServerFetch}
|
|
603
|
+
${cloudflareTransport && hasLive ? "import { connectCloudflareFateStream } from 'cf-fate/client';\n" : ""}${cloudflareHelpers}
|
|
584
604
|
|
|
585
605
|
type FateAPI = InferFateAPI<typeof fateServer>;
|
|
586
606
|
|