@nkzw/fate 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +179 -1
- package/docs/api/classes/FateClient.md +40 -40
- package/docs/api/functions/clientRoot.md +1 -1
- package/docs/api/functions/createClient.md +1 -1
- package/docs/api/functions/createGraphQLTransport.md +1 -1
- package/docs/api/functions/createHTTPTransport.md +1 -1
- package/docs/api/functions/createTRPCTransport.md +1 -1
- package/docs/api/functions/defer.md +1 -1
- package/docs/api/functions/getDeferredMetadata.md +1 -1
- package/docs/api/functions/getListEntries.md +1 -1
- package/docs/api/functions/getSelectionPlan.md +1 -1
- package/docs/api/functions/graphqlMutation.md +1 -1
- package/docs/api/functions/isDeferred.md +1 -1
- package/docs/api/functions/isRecord.md +1 -1
- package/docs/api/functions/isViewTag.md +1 -1
- package/docs/api/functions/liveConnectionTopic.md +1 -1
- package/docs/api/functions/liveEntityTopic.md +1 -1
- package/docs/api/functions/liveGlobalConnectionTopic.md +1 -1
- package/docs/api/functions/mutation.md +1 -1
- package/docs/api/functions/toEntityId.md +1 -1
- package/docs/api/functions/view.md +1 -1
- package/docs/api/interfaces/FateThenable.md +3 -3
- package/docs/api/interfaces/Transport.md +7 -7
- package/docs/api/server/classes/FateRequestError.md +5 -5
- package/docs/api/server/drizzle/functions/createDrizzleFate.md +1 -1
- package/docs/api/server/drizzle/functions/createDrizzleSourceAdapter.md +1 -1
- package/docs/api/server/drizzle/functions/createDrizzleSourceRegistry.md +1 -1
- package/docs/api/server/drizzle/type-aliases/DrizzleManyToManyConfig.md +1 -1
- package/docs/api/server/drizzle/type-aliases/DrizzleManyToManyInput.md +1 -1
- package/docs/api/server/drizzle/type-aliases/DrizzleQueryExtra.md +3 -3
- package/docs/api/server/drizzle/type-aliases/DrizzleSourceAdapter.md +9 -9
- package/docs/api/server/drizzle/type-aliases/DrizzleViewConfig.md +1 -1
- package/docs/api/server/functions/bindSourceProcedures.md +1 -1
- package/docs/api/server/functions/computed.md +1 -1
- package/docs/api/server/functions/count.md +1 -1
- package/docs/api/server/functions/createFateFetchHandler.md +1 -1
- package/docs/api/server/functions/createFateServer.md +1 -1
- package/docs/api/server/functions/createHonoFateHandler.md +1 -1
- package/docs/api/server/functions/createLiveEventBus.md +1 -1
- package/docs/api/server/functions/createNestedSourcePlan.md +1 -1
- package/docs/api/server/functions/createResolver.md +1 -1
- package/docs/api/server/functions/createSourcePlan.md +1 -1
- package/docs/api/server/functions/createSourceProcedures.md +1 -1
- package/docs/api/server/functions/dataView.md +1 -1
- package/docs/api/server/functions/field.md +1 -1
- package/docs/api/server/functions/getNestedSelection.md +1 -1
- package/docs/api/server/functions/getScopedArgs.md +1 -1
- package/docs/api/server/functions/hasNestedSelection.md +1 -1
- package/docs/api/server/functions/list.md +1 -1
- package/docs/api/server/functions/refetchSourceById.md +1 -1
- package/docs/api/server/functions/resolveSourceById.md +1 -1
- package/docs/api/server/functions/resolveSourceByIds.md +1 -1
- package/docs/api/server/functions/resolveSourceConnection.md +1 -1
- package/docs/api/server/functions/resolver.md +1 -1
- package/docs/api/server/functions/toPrismaSelect.md +1 -1
- package/docs/api/server/functions/withConnection.md +1 -1
- package/docs/api/server/prisma/functions/createPrismaFate.md +1 -1
- package/docs/api/server/prisma/functions/createPrismaSourceAdapter.md +1 -1
- package/docs/api/server/prisma/functions/createPrismaSourceRegistry.md +1 -1
- package/docs/api/server/prisma/functions/prismaConnectionArgs.md +1 -1
- package/docs/api/server/prisma/type-aliases/PrismaDelegate.md +4 -4
- package/docs/api/server/prisma/type-aliases/PrismaQueryExtra.md +1 -1
- package/docs/api/server/prisma/type-aliases/PrismaSourceAdapter.md +9 -9
- package/docs/api/server/prisma/type-aliases/PrismaViewConfig.md +1 -1
- package/docs/api/server/type-aliases/ComputedField.md +5 -5
- package/docs/api/server/type-aliases/ComputedSelection.md +1 -1
- package/docs/api/server/type-aliases/ConnectionItem.md +3 -3
- package/docs/api/server/type-aliases/ConnectionPagination.md +5 -5
- package/docs/api/server/type-aliases/ConnectionResult.md +3 -3
- package/docs/api/server/type-aliases/CountSelection.md +4 -4
- package/docs/api/server/type-aliases/CountWhere.md +1 -1
- package/docs/api/server/type-aliases/DataViewListOptions.md +2 -2
- package/docs/api/server/type-aliases/DataViewOrderBy.md +1 -1
- package/docs/api/server/type-aliases/DataViewOrderDirection.md +1 -1
- package/docs/api/server/type-aliases/DataViewResult.md +1 -1
- package/docs/api/server/type-aliases/Entity.md +1 -1
- package/docs/api/server/type-aliases/FateServer.md +5 -5
- package/docs/api/server/type-aliases/FateServerManifest.md +1 -1
- package/docs/api/server/type-aliases/FieldSelection.md +3 -3
- package/docs/api/server/type-aliases/LiveConnectionEventType.md +1 -1
- package/docs/api/server/type-aliases/LiveConnectionSourceEvent.md +1 -1
- package/docs/api/server/type-aliases/LiveEventBus.md +1 -1
- package/docs/api/server/type-aliases/LiveEventType.md +1 -1
- package/docs/api/server/type-aliases/LiveSourceEvent.md +1 -1
- package/docs/api/server/type-aliases/NativeFateAPI.md +4 -4
- package/docs/api/server/type-aliases/OrderDirection.md +1 -1
- package/docs/api/server/type-aliases/SourceConfig.md +6 -6
- package/docs/api/server/type-aliases/SourceDefinition.md +6 -6
- package/docs/api/server/type-aliases/SourceOrder.md +1 -1
- package/docs/api/server/type-aliases/SourceOrderField.md +3 -3
- package/docs/api/server/type-aliases/SourcePlan.md +1 -1
- package/docs/api/server/type-aliases/SourcePlanNode.md +1 -1
- package/docs/api/server/type-aliases/SourceRegistry.md +1 -1
- package/docs/api/server/type-aliases/SourceRelation.md +1 -1
- package/docs/api/server/type-aliases/SourceRelationConfig.md +1 -1
- package/docs/api/server/variables/byIdInput.md +1 -1
- package/docs/api/server/variables/connectionArgs.md +1 -1
- package/docs/api/type-aliases/ConnectionMetadata.md +1 -1
- package/docs/api/type-aliases/ConnectionRef.md +1 -1
- package/docs/api/type-aliases/Deferred.md +1 -1
- package/docs/api/type-aliases/DeferredMetadata.md +1 -1
- package/docs/api/type-aliases/DeferredSelection.md +1 -1
- package/docs/api/type-aliases/DeferredSnapshot.md +1 -1
- package/docs/api/type-aliases/Entity.md +2 -2
- package/docs/api/type-aliases/EntityId.md +1 -1
- package/docs/api/type-aliases/FateDehydratedState.md +1 -1
- package/docs/api/type-aliases/FateLiveConnectionEvent.md +1 -1
- package/docs/api/type-aliases/FateLiveEvent.md +1 -1
- package/docs/api/type-aliases/FateMutations.md +1 -1
- package/docs/api/type-aliases/FateOperation.md +1 -1
- package/docs/api/type-aliases/FateProtocolRequest.md +1 -1
- package/docs/api/type-aliases/FateProtocolResponse.md +1 -1
- package/docs/api/type-aliases/FateRecord.md +1 -1
- package/docs/api/type-aliases/FateRoots.md +1 -1
- package/docs/api/type-aliases/GraphQLMutationDefinition.md +1 -1
- package/docs/api/type-aliases/GraphQLMutationInput.md +1 -1
- package/docs/api/type-aliases/GraphQLMutationMap.md +1 -1
- package/docs/api/type-aliases/GraphQLMutationOutput.md +1 -1
- package/docs/api/type-aliases/GraphQLTransportOptions.md +11 -11
- package/docs/api/type-aliases/HydrateOptions.md +1 -1
- package/docs/api/type-aliases/HydrationLimits.md +1 -1
- package/docs/api/type-aliases/InferFateAPI.md +1 -1
- package/docs/api/type-aliases/List.md +1 -1
- package/docs/api/type-aliases/ListEntry.md +1 -1
- package/docs/api/type-aliases/ListItem.md +1 -1
- package/docs/api/type-aliases/Mask.md +1 -1
- package/docs/api/type-aliases/MutationDefinition.md +1 -1
- package/docs/api/type-aliases/MutationEntity.md +1 -1
- package/docs/api/type-aliases/MutationIdentifier.md +1 -1
- package/docs/api/type-aliases/MutationInput.md +1 -1
- package/docs/api/type-aliases/MutationResult.md +1 -1
- package/docs/api/type-aliases/NodesItem.md +1 -1
- package/docs/api/type-aliases/Pagination.md +5 -5
- package/docs/api/type-aliases/Request.md +1 -1
- package/docs/api/type-aliases/RequestMode.md +1 -1
- package/docs/api/type-aliases/RequestOptions.md +1 -1
- package/docs/api/type-aliases/RequestResult.md +1 -1
- package/docs/api/type-aliases/Selection.md +1 -1
- package/docs/api/type-aliases/Snapshot.md +1 -1
- package/docs/api/type-aliases/TypeConfig.md +4 -4
- package/docs/api/type-aliases/View.md +1 -1
- package/docs/api/type-aliases/ViewData.md +1 -1
- package/docs/api/type-aliases/ViewEntity.md +1 -1
- package/docs/api/type-aliases/ViewEntityName.md +1 -1
- package/docs/api/type-aliases/ViewRef.md +1 -1
- package/docs/api/type-aliases/ViewSelection.md +1 -1
- package/docs/api/type-aliases/ViewSnapshot.md +1 -1
- package/docs/api/type-aliases/ViewTag.md +1 -1
- package/docs/api/variables/ConnectionTag.md +1 -1
- package/docs/api/variables/DeferTag.md +1 -1
- package/docs/api/variables/DeferredTag.md +1 -1
- package/docs/integrations/cloudflare.md +19 -1
- package/docs/integrations/void.md +17 -1
- package/lib/{executor-Dh-MLUXc.d.mts → executor-C8HNogYG.d.mts} +1 -1
- package/lib/{graphqlTransport-IFgmY-Qq.mjs → graphqlTransport-DSBVS2Fq.mjs} +20 -15
- package/lib/{graphqlTransport-B3cbhvJX.d.mts → graphqlTransport-DskuXeUP.d.mts} +1 -1
- package/lib/graphqlTransport.d.mts +1 -1
- package/lib/graphqlTransport.mjs +1 -1
- package/lib/index.d.mts +4 -4
- package/lib/index.mjs +36 -25
- package/lib/{list-BrL6PD_6.d.mts → list-sI2UPhHc.d.mts} +1 -1
- package/lib/list.d.mts +1 -1
- package/lib/{liveTopics-JIDh3t3P.mjs → liveTopics-uVP0LG-Q.mjs} +1 -1
- package/lib/{record-BkvZwvFk.d.mts → record-CZyyeLa3.d.mts} +2 -2
- package/lib/server/drizzle.d.mts +2 -2
- package/lib/server/drizzle.mjs +43 -31
- package/lib/server/prisma.d.mts +2 -2
- package/lib/server/prisma.mjs +10 -8
- package/lib/server.d.mts +3 -3
- package/lib/server.mjs +23 -20
- package/lib/{sourceRouter-N9Vp0Cj6.mjs → sourceRouter-DSaADXSf.mjs} +8 -4
- package/lib/{transport-BjGm__3t.d.mts → transport-DhaVVq4P.d.mts} +3 -2
- package/lib/vite.mjs +6 -5
- package/package.json +4 -4
package/lib/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as isRecord } from "./record-B07VwXd-.mjs";
|
|
2
|
-
import { a as errorCodeFromStatus, c as cloneArgs, d as hashArgs, f as paginationArgKeys, i as FateRequestError, l as combineArgsPayload, m as scopeArgsPayload, n as liveEntityTopic, p as resolvedArgsFromPlan, r as liveGlobalConnectionTopic, s as applyArgsPayloadToPlan, t as liveConnectionTopic, u as filterConnectionArgs } from "./liveTopics-
|
|
2
|
+
import { a as errorCodeFromStatus, c as cloneArgs, d as hashArgs, f as paginationArgKeys, i as FateRequestError, l as combineArgsPayload, m as scopeArgsPayload, n as liveEntityTopic, p as resolvedArgsFromPlan, r as liveGlobalConnectionTopic, s as applyArgsPayloadToPlan, t as liveConnectionTopic, u as filterConnectionArgs } from "./liveTopics-uVP0LG-Q.mjs";
|
|
3
3
|
import { t as getListEntries } from "./list-_6fXYLtJ.mjs";
|
|
4
|
-
import { n as graphqlMutation, t as createGraphQLTransport } from "./graphqlTransport-
|
|
4
|
+
import { n as graphqlMutation, t as createGraphQLTransport } from "./graphqlTransport-DSBVS2Fq.mjs";
|
|
5
5
|
//#region src/cache.ts
|
|
6
6
|
var ViewDataCache = class {
|
|
7
7
|
constructor() {
|
|
@@ -306,7 +306,7 @@ const isStringArray = (value) => Array.isArray(value) && value.every((entry) =>
|
|
|
306
306
|
const hasDuplicates = (values) => new Set(values).size !== values.length;
|
|
307
307
|
const isUniqueStringArray = (value) => isStringArray(value) && !hasDuplicates(value);
|
|
308
308
|
const hasOnlyKeys = (value, keys) => Object.keys(value).every((key) => keys.has(key));
|
|
309
|
-
const listKeys = new Set([
|
|
309
|
+
const listKeys = /* @__PURE__ */ new Set([
|
|
310
310
|
"backwardPageLimit",
|
|
311
311
|
"cursors",
|
|
312
312
|
"forwardPageLimit",
|
|
@@ -317,18 +317,18 @@ const listKeys = new Set([
|
|
|
317
317
|
"pendingAfterIds",
|
|
318
318
|
"pendingBeforeIds"
|
|
319
319
|
]);
|
|
320
|
-
const paginationKeys = new Set([
|
|
320
|
+
const paginationKeys = /* @__PURE__ */ new Set([
|
|
321
321
|
"hasNext",
|
|
322
322
|
"hasPrevious",
|
|
323
323
|
"nextCursor",
|
|
324
324
|
"previousCursor"
|
|
325
325
|
]);
|
|
326
|
-
const clientStateKeys = new Set([
|
|
326
|
+
const clientStateKeys = /* @__PURE__ */ new Set([
|
|
327
327
|
"rootLists",
|
|
328
328
|
"rootRequests",
|
|
329
329
|
"store"
|
|
330
330
|
]);
|
|
331
|
-
const storeStateKeys = new Set([
|
|
331
|
+
const storeStateKeys = /* @__PURE__ */ new Set([
|
|
332
332
|
"coverage",
|
|
333
333
|
"lists",
|
|
334
334
|
"records"
|
|
@@ -438,7 +438,7 @@ function intersects(a, b) {
|
|
|
438
438
|
return false;
|
|
439
439
|
}
|
|
440
440
|
//#endregion
|
|
441
|
-
//#region ../../node_modules/.pnpm/@trpc+server@11.
|
|
441
|
+
//#region ../../node_modules/.pnpm/@trpc+server@11.18.0_typescript@6.0.3/node_modules/@trpc/server/dist/getErrorShape-BPSzUA7W.mjs
|
|
442
442
|
var __create = Object.create;
|
|
443
443
|
var __defProp = Object.defineProperty;
|
|
444
444
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -701,7 +701,11 @@ const getSelectionPlan = (viewComposition, ref) => {
|
|
|
701
701
|
append: selection.live.append === "visible" ? "visible" : "edge",
|
|
702
702
|
prepend: selection.live.prepend === "visible" ? "visible" : "edge"
|
|
703
703
|
});
|
|
704
|
-
if (selection.args && isRecord(selection.args))
|
|
704
|
+
if (selection.args && isRecord(selection.args)) {
|
|
705
|
+
const clonedArgs = cloneArgs(selection.args, "args");
|
|
706
|
+
const ignoreKeys = isRecord(selection.items) && isRecord(selection.items.node) ? paginationArgKeys : void 0;
|
|
707
|
+
assignArgs("", clonedArgs, ignoreKeys);
|
|
708
|
+
}
|
|
705
709
|
const { args: _args, live: _live, ...withoutArgs } = selection;
|
|
706
710
|
walk(withoutArgs, prefix, "connection");
|
|
707
711
|
return;
|
|
@@ -732,7 +736,11 @@ const getSelectionPlan = (viewComposition, ref) => {
|
|
|
732
736
|
append: selectionObject.live.append === "visible" ? "visible" : "edge",
|
|
733
737
|
prepend: selectionObject.live.prepend === "visible" ? "visible" : "edge"
|
|
734
738
|
});
|
|
735
|
-
if (selectionObject.args && isRecord(selectionObject.args))
|
|
739
|
+
if (selectionObject.args && isRecord(selectionObject.args)) {
|
|
740
|
+
const clonedArgs = cloneArgs(selectionObject.args, path);
|
|
741
|
+
const ignoreKeys = isRecord(selectionObject.items) && isRecord(selectionObject.items.node) ? paginationArgKeys : void 0;
|
|
742
|
+
assignArgs(path, clonedArgs, ignoreKeys);
|
|
743
|
+
}
|
|
736
744
|
const { args: _ignored, live: _live, ...withoutArgs } = selectionObject;
|
|
737
745
|
walk(withoutArgs, path, "connection");
|
|
738
746
|
continue;
|
|
@@ -740,7 +748,9 @@ const getSelectionPlan = (viewComposition, ref) => {
|
|
|
740
748
|
const hasArgs = selectionObject.args && isRecord(selectionObject.args);
|
|
741
749
|
let selectionWithoutArgs = selectionObject;
|
|
742
750
|
if (hasArgs) {
|
|
743
|
-
|
|
751
|
+
const clonedArgs = cloneArgs(selectionObject.args, path);
|
|
752
|
+
const ignoreKeys = isRecord(selectionObject.items) && isRecord(selectionObject.items?.node) ? paginationArgKeys : void 0;
|
|
753
|
+
assignArgs(path, clonedArgs, ignoreKeys);
|
|
744
754
|
const { args: _args, ...rest } = selectionObject;
|
|
745
755
|
selectionWithoutArgs = rest;
|
|
746
756
|
}
|
|
@@ -821,7 +831,7 @@ function wrapMutation(client, identifier) {
|
|
|
821
831
|
const snapshots = /* @__PURE__ */ new Map();
|
|
822
832
|
const listSnapshots = deleteRecord || optimisticRecord ? /* @__PURE__ */ new Map() : void 0;
|
|
823
833
|
const optimisticSelection = optimisticRecord ? collectImplicitSelectedPaths(optimisticRecord) : void 0;
|
|
824
|
-
const selection = viewSelection || optimisticSelection ? new Set([...viewSelection ? [...viewSelection] : [], ...optimisticSelection ? [...optimisticSelection] : []]) : /* @__PURE__ */ new Set();
|
|
834
|
+
const selection = viewSelection || optimisticSelection ? /* @__PURE__ */ new Set([...viewSelection ? [...viewSelection] : [], ...optimisticSelection ? [...optimisticSelection] : []]) : /* @__PURE__ */ new Set();
|
|
825
835
|
if (deleteRecord && id == null) throw new Error(`fate: Mutation '${identifier.key}' requires an 'id' to delete.`);
|
|
826
836
|
const optimisticToken = optimisticEntityId ? client.registerOptimisticUpdate(optimisticEntityId, optimisticSelection ?? emptySet$1) : null;
|
|
827
837
|
if (optimisticRecord && optimisticEntityId) client.write(identifier.entity, optimisticRecord, optimisticSelection ?? emptySet$1, snapshots, plan, null, null, insert, listSnapshots);
|
|
@@ -1063,9 +1073,9 @@ var Store = class {
|
|
|
1063
1073
|
this.records = records;
|
|
1064
1074
|
this.rebuildIndexes();
|
|
1065
1075
|
const changedRecordIds = /* @__PURE__ */ new Set();
|
|
1066
|
-
for (const id of new Set([...previousRecords.keys(), ...records.keys()])) if (!areHydrationValuesEqual(previousRecords.get(id), records.get(id)) || !areMasksEqual(previousCoverage.get(id), coverage.get(id))) changedRecordIds.add(id);
|
|
1076
|
+
for (const id of /* @__PURE__ */ new Set([...previousRecords.keys(), ...records.keys()])) if (!areHydrationValuesEqual(previousRecords.get(id), records.get(id)) || !areMasksEqual(previousCoverage.get(id), coverage.get(id))) changedRecordIds.add(id);
|
|
1067
1077
|
const changedListKeys = /* @__PURE__ */ new Set();
|
|
1068
|
-
for (const key of new Set([...previousLists.keys(), ...lists.keys()])) if (!areHydrationValuesEqual(previousLists.get(key), lists.get(key))) changedListKeys.add(key);
|
|
1078
|
+
for (const key of /* @__PURE__ */ new Set([...previousLists.keys(), ...lists.keys()])) if (!areHydrationValuesEqual(previousLists.get(key), lists.get(key))) changedListKeys.add(key);
|
|
1069
1079
|
const notify = () => {
|
|
1070
1080
|
for (const id of changedRecordIds) this.notify(id);
|
|
1071
1081
|
for (const key of changedListKeys) this.notifyListSubscribers(key);
|
|
@@ -1439,7 +1449,7 @@ var Store = class {
|
|
|
1439
1449
|
}
|
|
1440
1450
|
return ids;
|
|
1441
1451
|
}
|
|
1442
|
-
if (isNodeRef(value)) return new Set([getNodeRefId(value)]);
|
|
1452
|
+
if (isNodeRef(value)) return /* @__PURE__ */ new Set([getNodeRefId(value)]);
|
|
1443
1453
|
return null;
|
|
1444
1454
|
}
|
|
1445
1455
|
addRecordFieldReferenceIndex(id, field, value) {
|
|
@@ -1994,6 +2004,11 @@ var FateClient = class {
|
|
|
1994
2004
|
if (!config) throw new Error(`fate: Unknown entity type '${type}'.`);
|
|
1995
2005
|
return config;
|
|
1996
2006
|
}
|
|
2007
|
+
getListNodeType(type, field) {
|
|
2008
|
+
const descriptor = this.getTypeConfig(type).fields?.[field];
|
|
2009
|
+
if (!descriptor || descriptor === "scalar" || !("listOf" in descriptor)) throw new Error(`fate: Could not find node type for '${type}.${field}'.`);
|
|
2010
|
+
return descriptor.listOf;
|
|
2011
|
+
}
|
|
1997
2012
|
async executeMutation(key, input, select, options = {}) {
|
|
1998
2013
|
if (!this.transport.mutate) throw new Error(`fate: transport does not support mutations. Please provide a 'mutate' implementation in your transport.`);
|
|
1999
2014
|
const baseRecord = input && typeof input === "object" ? input : void 0;
|
|
@@ -2655,9 +2670,7 @@ var FateClient = class {
|
|
|
2655
2670
|
if (!connectionPayload) return this.store.getListState(connection.key);
|
|
2656
2671
|
const incomingIds = [];
|
|
2657
2672
|
const incomingCursors = [];
|
|
2658
|
-
const
|
|
2659
|
-
const nodeType = fieldConfig && (fieldConfig === "scalar" ? null : "listOf" in fieldConfig ? fieldConfig.listOf : null) || null;
|
|
2660
|
-
if (!nodeType) throw new Error(`fate: Could not find node type for '${owner.type}.${connection.field}'.`);
|
|
2673
|
+
const nodeType = this.getListNodeType(owner.type, connection.field);
|
|
2661
2674
|
for (const entry of connectionPayload.items) {
|
|
2662
2675
|
const { node } = entry;
|
|
2663
2676
|
const id = this.write(nodeType, node, nodeSelection, void 0, plan);
|
|
@@ -3184,7 +3197,8 @@ var FateClient = class {
|
|
|
3184
3197
|
this.snapshotList(defaultListKey, listSnapshots);
|
|
3185
3198
|
this.store.setList(defaultListKey, nextDefaultListState);
|
|
3186
3199
|
}
|
|
3187
|
-
|
|
3200
|
+
const nextFieldIds = pending ? getListEntries(nextDefaultListState).map(({ id }) => id) : nextDefaultListState.ids;
|
|
3201
|
+
nextField = createNodeRefsForIds(nextFieldIds, current);
|
|
3188
3202
|
} else {
|
|
3189
3203
|
const currentIds = current.map((item) => isNodeRef(item) ? getNodeRefId(item) : null).filter((id) => id != null);
|
|
3190
3204
|
const nextDefaultListState = { ids: insert === "before" ? [entityId, ...currentIds] : [...currentIds, entityId] };
|
|
@@ -3287,11 +3301,8 @@ var FateClient = class {
|
|
|
3287
3301
|
} else connection.pagination = void 0;
|
|
3288
3302
|
}
|
|
3289
3303
|
const { id: ownerRawId, type: parentType } = parseEntityId(parentId);
|
|
3290
|
-
const childType = (() => {
|
|
3291
|
-
for (const item of value) if (isNodeRef(item)) return parseEntityId(getNodeRefId(item)).type;
|
|
3292
|
-
return "";
|
|
3293
|
-
})();
|
|
3294
3304
|
if (parentType) {
|
|
3305
|
+
const childType = this.getListNodeType(parentType, key);
|
|
3295
3306
|
const metadata = {
|
|
3296
3307
|
args: (() => {
|
|
3297
3308
|
if (!fieldArgs?.value && ownerRawId === void 0) return;
|
|
@@ -3759,8 +3770,8 @@ function createHTTPTransport({ eventSource, fetch: fetchImpl = defaultFetch, hea
|
|
|
3759
3770
|
const [record] = await transport.fetchById(subscription.type, [subscription.targetId], select, subscription.args);
|
|
3760
3771
|
return record;
|
|
3761
3772
|
};
|
|
3762
|
-
const resolveConnectionNode = async (subscription, id) => {
|
|
3763
|
-
const [record] = await transport.fetchById(
|
|
3773
|
+
const resolveConnectionNode = async (subscription, id, nodeType) => {
|
|
3774
|
+
const [record] = await transport.fetchById(nodeType, [id], subscription.select, subscription.selectionArgs);
|
|
3764
3775
|
return record;
|
|
3765
3776
|
};
|
|
3766
3777
|
transport.subscribeById = (type, id, select, args, handlers) => {
|
|
@@ -3867,7 +3878,7 @@ function createHTTPTransport({ eventSource, fetch: fetchImpl = defaultFetch, hea
|
|
|
3867
3878
|
reportSubscriptionError(subscription, /* @__PURE__ */ new Error(`fate(http): Live connection event for '${procedure}' missed a node id.`));
|
|
3868
3879
|
return;
|
|
3869
3880
|
}
|
|
3870
|
-
resolveConnectionNode(subscription, id).then(sendNode).catch((error) => reportSubscriptionError(subscription, error));
|
|
3881
|
+
resolveConnectionNode(subscription, id, nodeType).then(sendNode).catch((error) => reportSubscriptionError(subscription, error));
|
|
3871
3882
|
};
|
|
3872
3883
|
liveSubscriptions.set(liveId, subscription);
|
|
3873
3884
|
if (!liveConnector) {
|
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-sI2UPhHc.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-DhaVVq4P.mjs";
|
|
2
|
+
import { N as DataViewResult, S as ConnectionResult, k as DataView, l as SourceDefinition, t as SourceRegistry } from "./executor-C8HNogYG.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 { r as AnyRecord, rt as QueryProcedure } from "../transport-
|
|
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-DhaVVq4P.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-C8HNogYG.mjs";
|
|
3
3
|
import { AnyColumn, SQLWrapper, Table } from "drizzle-orm";
|
|
4
4
|
|
|
5
5
|
//#region src/server/drizzle.d.ts
|
package/lib/server/drizzle.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as isRecord } from "../record-B07VwXd-.mjs";
|
|
2
|
-
import { O as withConnection, S as isDataView, c as resolveSourceConnection, d as createSourceDefinitions, f as createSourcePlan, g as attachComputedState, i as createSourceRegistry, l as collectDataViewConfigs, o as resolveSourceById, p as getDataViewSourceConfig, s as resolveSourceByIds, t as bindSourceProcedures } from "../sourceRouter-
|
|
2
|
+
import { O as withConnection, S as isDataView, c as resolveSourceConnection, d as createSourceDefinitions, f as createSourcePlan, g as attachComputedState, i as createSourceRegistry, l as collectDataViewConfigs, o as resolveSourceById, p as getDataViewSourceConfig, s as resolveSourceByIds, t as bindSourceProcedures } from "../sourceRouter-DSaADXSf.mjs";
|
|
3
3
|
import { Many, and, asc, createTableRelationsHelpers, desc, eq, extractTablesRelationalConfig, getTableColumns, gt, inArray, is, isTable, lt, normalizeRelation, or, sql } from "drizzle-orm";
|
|
4
4
|
//#region src/server/drizzle.ts
|
|
5
5
|
/**
|
|
@@ -426,7 +426,8 @@ function createDrizzleSourceAdapter({ db, nestedPaginationConcurrency, schema, v
|
|
|
426
426
|
if (!sourceRelation || sourceRelation.kind !== "many" && sourceRelation.kind !== "manyToMany") throw new Error(`Computed count ${node.source.view.typeName}.${field} requires a collection relation named ${selection.relation}.`);
|
|
427
427
|
const parentKeys = compactKeys(items.map((item) => item[sourceRelation.localKey]));
|
|
428
428
|
if (parentKeys.length === 0) continue;
|
|
429
|
-
const
|
|
429
|
+
const childSource = resolveSource(sourceRelation.source);
|
|
430
|
+
const childConfig = getSourceConfig(childSource);
|
|
430
431
|
let rows;
|
|
431
432
|
if (sourceRelation.kind === "manyToMany") {
|
|
432
433
|
const throughConfig = getSourceConfig(node.source).manyToMany?.[selection.relation];
|
|
@@ -454,15 +455,17 @@ function createDrizzleSourceAdapter({ db, nestedPaginationConcurrency, schema, v
|
|
|
454
455
|
}
|
|
455
456
|
};
|
|
456
457
|
const fetchManyRelation = async ({ ctx, items, relationNode, sourceRelation }) => {
|
|
457
|
-
const
|
|
458
|
+
const childSource = resolveSource(sourceRelation.source);
|
|
459
|
+
const childConfig = getSourceConfig(childSource);
|
|
458
460
|
const parentKeys = compactKeys(items.map((item) => item[sourceRelation.localKey]));
|
|
459
461
|
if (parentKeys.length === 0) return /* @__PURE__ */ new Map();
|
|
460
|
-
const
|
|
462
|
+
const rows = await queryRows({
|
|
461
463
|
ctx,
|
|
462
464
|
extraFields: [sourceRelation.foreignKey],
|
|
463
465
|
node: relationNode,
|
|
464
466
|
where: inArray(getColumn(childConfig.columns, sourceRelation.foreignKey), parentKeys)
|
|
465
|
-
})
|
|
467
|
+
});
|
|
468
|
+
const hydrated = await hydrateRows(rows, relationNode, ctx);
|
|
466
469
|
const byParentKey = /* @__PURE__ */ new Map();
|
|
467
470
|
for (const item of hydrated) {
|
|
468
471
|
const key = item[sourceRelation.foreignKey];
|
|
@@ -484,17 +487,19 @@ function createDrizzleSourceAdapter({ db, nestedPaginationConcurrency, schema, v
|
|
|
484
487
|
items: [],
|
|
485
488
|
pageSize
|
|
486
489
|
});
|
|
490
|
+
const rows = await queryNodePage({
|
|
491
|
+
baseWhere: eq(getColumn(childConfig.columns, sourceRelation.foreignKey), parentKey),
|
|
492
|
+
ctx,
|
|
493
|
+
cursor,
|
|
494
|
+
direction,
|
|
495
|
+
node: relationNode,
|
|
496
|
+
take: pageSize + 1
|
|
497
|
+
});
|
|
498
|
+
const hydrated = await hydrateRows(rows, relationNode, ctx);
|
|
487
499
|
return buildConnection({
|
|
488
500
|
cursor,
|
|
489
501
|
direction,
|
|
490
|
-
items:
|
|
491
|
-
baseWhere: eq(getColumn(childConfig.columns, sourceRelation.foreignKey), parentKey),
|
|
492
|
-
ctx,
|
|
493
|
-
cursor,
|
|
494
|
-
direction,
|
|
495
|
-
node: relationNode,
|
|
496
|
-
take: pageSize + 1
|
|
497
|
-
}), relationNode, ctx),
|
|
502
|
+
items: hydrated,
|
|
498
503
|
pageSize
|
|
499
504
|
});
|
|
500
505
|
};
|
|
@@ -529,19 +534,21 @@ function createDrizzleSourceAdapter({ db, nestedPaginationConcurrency, schema, v
|
|
|
529
534
|
items: [],
|
|
530
535
|
pageSize
|
|
531
536
|
});
|
|
537
|
+
const rows = await queryManyToManyPage({
|
|
538
|
+
ctx,
|
|
539
|
+
cursor,
|
|
540
|
+
direction,
|
|
541
|
+
node: relationNode,
|
|
542
|
+
parentKey,
|
|
543
|
+
sourceRelation,
|
|
544
|
+
take: pageSize + 1,
|
|
545
|
+
through
|
|
546
|
+
});
|
|
547
|
+
const hydrated = await hydrateRows(rows, relationNode, ctx);
|
|
532
548
|
return buildConnection({
|
|
533
549
|
cursor,
|
|
534
550
|
direction,
|
|
535
|
-
items:
|
|
536
|
-
ctx,
|
|
537
|
-
cursor,
|
|
538
|
-
direction,
|
|
539
|
-
node: relationNode,
|
|
540
|
-
parentKey,
|
|
541
|
-
sourceRelation,
|
|
542
|
-
take: pageSize + 1,
|
|
543
|
-
through
|
|
544
|
-
}), relationNode, ctx),
|
|
551
|
+
items: hydrated,
|
|
545
552
|
pageSize
|
|
546
553
|
});
|
|
547
554
|
};
|
|
@@ -558,10 +565,11 @@ function createDrizzleSourceAdapter({ db, nestedPaginationConcurrency, schema, v
|
|
|
558
565
|
});
|
|
559
566
|
const parentKeys = compactKeys(items.map((item) => item[sourceRelation.localKey]));
|
|
560
567
|
if (parentKeys.length === 0) return /* @__PURE__ */ new Map();
|
|
561
|
-
const
|
|
568
|
+
const rows = await getDb(ctx).select({
|
|
562
569
|
...buildSelection(relationNode),
|
|
563
570
|
parentKey: through.localColumn
|
|
564
|
-
}).from(through.table).innerJoin(childConfig.table, eq(through.foreignColumn, getColumn(childConfig.columns, sourceRelation.foreignKey))).where(inArray(through.localColumn, parentKeys)).orderBy(...getQueryOrder("forward", relationNode, childConfig.columns))
|
|
571
|
+
}).from(through.table).innerJoin(childConfig.table, eq(through.foreignColumn, getColumn(childConfig.columns, sourceRelation.foreignKey))).where(inArray(through.localColumn, parentKeys)).orderBy(...getQueryOrder("forward", relationNode, childConfig.columns));
|
|
572
|
+
const hydrated = await hydrateRows(rows, relationNode, ctx);
|
|
565
573
|
const byParentKey = /* @__PURE__ */ new Map();
|
|
566
574
|
for (const item of hydrated) {
|
|
567
575
|
const entries = byParentKey.get(item.parentKey) ?? [];
|
|
@@ -579,11 +587,13 @@ function createDrizzleSourceAdapter({ db, nestedPaginationConcurrency, schema, v
|
|
|
579
587
|
if (sourceRelation.kind === "one") {
|
|
580
588
|
const childConfig = getSourceConfig(resolveSource(sourceRelation.source));
|
|
581
589
|
const childKeys = compactKeys(items.map((item) => item[sourceRelation.localKey]));
|
|
582
|
-
const
|
|
590
|
+
const childRows = childKeys.length ? await queryRows({
|
|
583
591
|
ctx,
|
|
584
592
|
node: relationNode,
|
|
585
593
|
where: inArray(getColumn(childConfig.columns, sourceRelation.foreignKey), childKeys)
|
|
586
|
-
}) : []
|
|
594
|
+
}) : [];
|
|
595
|
+
const children = await hydrateRows(childRows, relationNode, ctx);
|
|
596
|
+
const childByKey = mapByField(children, sourceRelation.foreignKey);
|
|
587
597
|
for (const item of items) {
|
|
588
598
|
const localKey = item[sourceRelation.localKey];
|
|
589
599
|
item[field] = localKey !== null && localKey !== void 0 ? childByKey.get(localKey) ?? null : null;
|
|
@@ -635,12 +645,13 @@ function createDrizzleSourceAdapter({ db, nestedPaginationConcurrency, schema, v
|
|
|
635
645
|
const fetchByIds = async ({ ctx, extra, ids, plan }) => {
|
|
636
646
|
if (!ids.length) return [];
|
|
637
647
|
const config = getSourceConfig(plan.source);
|
|
638
|
-
|
|
648
|
+
const rows = await queryRows({
|
|
639
649
|
ctx,
|
|
640
650
|
extraFields: extra?.extraFields,
|
|
641
651
|
node: plan.root,
|
|
642
652
|
where: inArray(getColumn(config.columns, plan.source.id), [...new Set(ids)])
|
|
643
|
-
})
|
|
653
|
+
});
|
|
654
|
+
return reorderByIds(ids, await hydrateRows(rows, plan.root, ctx));
|
|
644
655
|
};
|
|
645
656
|
const fetchById = async ({ ctx, extra, id, plan }) => (await fetchByIds({
|
|
646
657
|
ctx,
|
|
@@ -733,10 +744,11 @@ function createDrizzleFate({ procedure, ...options }) {
|
|
|
733
744
|
}),
|
|
734
745
|
procedures: (input) => {
|
|
735
746
|
const procedureInput = input;
|
|
736
|
-
|
|
747
|
+
const options = procedureInput && typeof procedureInput === "object" && "view" in procedureInput ? {
|
|
737
748
|
...procedureInput,
|
|
738
749
|
source: adapter.getSource(procedureInput.view)
|
|
739
|
-
} : adapter.getSource(input)
|
|
750
|
+
} : adapter.getSource(input);
|
|
751
|
+
return procedures(options);
|
|
740
752
|
},
|
|
741
753
|
resolveById: ({ ctx, extra, id, input, view }) => resolveSourceById({
|
|
742
754
|
ctx,
|
package/lib/server/prisma.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { r as AnyRecord, rt as QueryProcedure } from "../transport-
|
|
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-DhaVVq4P.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-C8HNogYG.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/server/prisma.d.ts
|
|
5
5
|
type PrismaDelegate = {
|
package/lib/server/prisma.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as isRecord } from "../record-B07VwXd-.mjs";
|
|
2
|
-
import { O as withConnection, S as isDataView, T as toPrismaSelect, c as resolveSourceConnection, d as createSourceDefinitions, f as createSourcePlan, g as attachComputedState, i as createSourceRegistry, l as collectDataViewConfigs, o as resolveSourceById, p as getDataViewSourceConfig, s as resolveSourceByIds, t as bindSourceProcedures } from "../sourceRouter-
|
|
2
|
+
import { O as withConnection, S as isDataView, T as toPrismaSelect, c as resolveSourceConnection, d as createSourceDefinitions, f as createSourcePlan, g as attachComputedState, i as createSourceRegistry, l as collectDataViewConfigs, o as resolveSourceById, p as getDataViewSourceConfig, s as resolveSourceByIds, t as bindSourceProcedures } from "../sourceRouter-DSaADXSf.mjs";
|
|
3
3
|
//#region src/server/prisma.ts
|
|
4
4
|
/**
|
|
5
5
|
* fate's Prisma integration.
|
|
@@ -159,13 +159,14 @@ function createPrismaSourceAdapter({ prisma, views }) {
|
|
|
159
159
|
const relation = source.relations?.[relationName];
|
|
160
160
|
if (!relation) continue;
|
|
161
161
|
const childSource = resolveSourceReference(relation.source);
|
|
162
|
+
const childItems = items.flatMap((item) => {
|
|
163
|
+
const value = item[relationName];
|
|
164
|
+
if (Array.isArray(value)) return value.filter(isRecord);
|
|
165
|
+
return isRecord(value) ? [value] : [];
|
|
166
|
+
});
|
|
162
167
|
await attachConflictingComputedCounts({
|
|
163
168
|
ctx,
|
|
164
|
-
items:
|
|
165
|
-
const value = item[relationName];
|
|
166
|
-
if (Array.isArray(value)) return value.filter(isRecord);
|
|
167
|
-
return isRecord(value) ? [value] : [];
|
|
168
|
-
}),
|
|
169
|
+
items: childItems,
|
|
169
170
|
node: relationNode,
|
|
170
171
|
source: childSource
|
|
171
172
|
});
|
|
@@ -307,10 +308,11 @@ function createPrismaFate({ procedure, ...options }) {
|
|
|
307
308
|
}),
|
|
308
309
|
procedures: (input) => {
|
|
309
310
|
const procedureInput = input;
|
|
310
|
-
|
|
311
|
+
const options = procedureInput && typeof procedureInput === "object" && "view" in procedureInput ? {
|
|
311
312
|
...procedureInput,
|
|
312
313
|
source: adapter.getSource(procedureInput.view)
|
|
313
|
-
} : adapter.getSource(input)
|
|
314
|
+
} : adapter.getSource(input);
|
|
315
|
+
return procedures(options);
|
|
314
316
|
},
|
|
315
317
|
resolveById: ({ ctx, extra, id, input, view }) => resolveSourceById({
|
|
316
318
|
ctx,
|
package/lib/server.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { nt as AnyProcedure, r as AnyRecord$1 } from "./transport-
|
|
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-DhaVVq4P.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-CZyyeLa3.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-C8HNogYG.mjs";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
|
|
6
6
|
//#region src/server/input.d.ts
|
package/lib/server.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as isRecord } from "./record-B07VwXd-.mjs";
|
|
2
|
-
import { d as hashArgs, i as FateRequestError, n as liveEntityTopic, o as toProtocolError, r as liveGlobalConnectionTopic, t as liveConnectionTopic, u as filterConnectionArgs } from "./liveTopics-
|
|
3
|
-
import { C as list, D as resolveConnection, E as connectionArgs, O as withConnection, 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 getScopedArgs, 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-
|
|
2
|
+
import { d as hashArgs, i as FateRequestError, n as liveEntityTopic, o as toProtocolError, r as liveGlobalConnectionTopic, t as liveConnectionTopic, u as filterConnectionArgs } from "./liveTopics-uVP0LG-Q.mjs";
|
|
3
|
+
import { C as list, D as resolveConnection, E as connectionArgs, O as withConnection, 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 getScopedArgs, 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-DSaADXSf.mjs";
|
|
4
4
|
import { EventEmitter, on } from "node:events";
|
|
5
5
|
//#region src/server/live.ts
|
|
6
6
|
const eventName = (type, id) => `${type}:${String(id)}`;
|
|
@@ -281,7 +281,7 @@ const parseInput = async (schema, value) => {
|
|
|
281
281
|
};
|
|
282
282
|
const isStringArray = (value) => Array.isArray(value) && value.every((entry) => typeof entry === "string");
|
|
283
283
|
const isProtocolId = (value) => typeof value === "string" || typeof value === "number";
|
|
284
|
-
const operationKinds = new Set([
|
|
284
|
+
const operationKinds = /* @__PURE__ */ new Set([
|
|
285
285
|
"byId",
|
|
286
286
|
"list",
|
|
287
287
|
"mutation",
|
|
@@ -402,7 +402,8 @@ function createFateServer({ context, lists, live, mutations, queries, roots, sou
|
|
|
402
402
|
if (!existing || sourceScore(source) > sourceScore(existing)) sourcesByType.set(source.view.typeName, source);
|
|
403
403
|
};
|
|
404
404
|
const visit = (view) => {
|
|
405
|
-
|
|
405
|
+
const source = sources.getSource(view);
|
|
406
|
+
registerSourceByType(source);
|
|
406
407
|
for (const field of Object.values(view.fields)) if (isDataView(field)) visit(field);
|
|
407
408
|
};
|
|
408
409
|
for (const [name, root] of Object.entries(roots)) {
|
|
@@ -588,15 +589,16 @@ function createFateServer({ context, lists, live, mutations, queries, roots, sou
|
|
|
588
589
|
args: operation.args,
|
|
589
590
|
select: select ?? operation.select
|
|
590
591
|
};
|
|
592
|
+
const data = event.type === "delete" ? null : await resolveLiveSourceData({
|
|
593
|
+
ctx: connection.ctx,
|
|
594
|
+
data: event.data,
|
|
595
|
+
id: event.id,
|
|
596
|
+
input,
|
|
597
|
+
registry: sources.registry,
|
|
598
|
+
source
|
|
599
|
+
});
|
|
591
600
|
sendLiveMessage(connection, {
|
|
592
|
-
event: livePayload(event,
|
|
593
|
-
ctx: connection.ctx,
|
|
594
|
-
data: event.data,
|
|
595
|
-
id: event.id,
|
|
596
|
-
input,
|
|
597
|
-
registry: sources.registry,
|
|
598
|
-
source
|
|
599
|
-
}), select ?? void 0),
|
|
601
|
+
event: livePayload(event, data, select ?? void 0),
|
|
600
602
|
id: operation.id,
|
|
601
603
|
kind: "next"
|
|
602
604
|
}, event.eventId);
|
|
@@ -666,15 +668,16 @@ function createFateServer({ context, lists, live, mutations, queries, roots, sou
|
|
|
666
668
|
args: operation.args,
|
|
667
669
|
select: select ?? operation.select
|
|
668
670
|
};
|
|
671
|
+
const data = event.type === "delete" ? null : await resolveLiveSourceData({
|
|
672
|
+
ctx: connection.ctx,
|
|
673
|
+
data: event.data,
|
|
674
|
+
id: event.id,
|
|
675
|
+
input,
|
|
676
|
+
registry: sources.registry,
|
|
677
|
+
source
|
|
678
|
+
});
|
|
669
679
|
sendLiveMessage(connection, {
|
|
670
|
-
event: livePayload(event,
|
|
671
|
-
ctx: connection.ctx,
|
|
672
|
-
data: event.data,
|
|
673
|
-
id: event.id,
|
|
674
|
-
input,
|
|
675
|
-
registry: sources.registry,
|
|
676
|
-
source
|
|
677
|
-
}), select ?? void 0),
|
|
680
|
+
event: livePayload(event, data, select ?? void 0),
|
|
678
681
|
id: operation.id,
|
|
679
682
|
kind: "next"
|
|
680
683
|
}, event.eventId);
|
|
@@ -38,7 +38,7 @@ const connectionInput = z.strictObject({
|
|
|
38
38
|
args: connectionArgs,
|
|
39
39
|
select: z.array(z.string())
|
|
40
40
|
});
|
|
41
|
-
const paginationArgKeys = new Set([
|
|
41
|
+
const paginationArgKeys = /* @__PURE__ */ new Set([
|
|
42
42
|
"after",
|
|
43
43
|
"before",
|
|
44
44
|
"first",
|
|
@@ -291,7 +291,8 @@ const applyComputedSelections = (node, select) => {
|
|
|
291
291
|
countSelect[selection.relation] = selection.where ? { where: selection.where } : true;
|
|
292
292
|
continue;
|
|
293
293
|
}
|
|
294
|
-
|
|
294
|
+
const target = ensureRelationSelect(select, node.path);
|
|
295
|
+
assignDependencyPath(target, selection.path);
|
|
295
296
|
}
|
|
296
297
|
}
|
|
297
298
|
for (const relation of node.relations.values()) applyComputedSelections(relation, select);
|
|
@@ -303,7 +304,10 @@ const collectResolverSelections = (node, select, args, context) => {
|
|
|
303
304
|
args,
|
|
304
305
|
context
|
|
305
306
|
}) : resolver.select;
|
|
306
|
-
if (addition && typeof addition === "object" && !Array.isArray(addition))
|
|
307
|
+
if (addition && typeof addition === "object" && !Array.isArray(addition)) {
|
|
308
|
+
const target = ensureRelationSelect(select, node.path);
|
|
309
|
+
mergeObject(target, addition);
|
|
310
|
+
}
|
|
307
311
|
}
|
|
308
312
|
for (const relation of node.relations.values()) collectResolverSelections(relation, select, args, context);
|
|
309
313
|
};
|
|
@@ -735,7 +739,7 @@ function createSourceDefinitions(configs, options) {
|
|
|
735
739
|
for (const [index, config] of configs.entries()) {
|
|
736
740
|
const source = sources[index];
|
|
737
741
|
const relations = {};
|
|
738
|
-
const relationFields = new Set([...Object.keys(config.relations ?? {}), ...Object.keys(config.view.fields).filter((field) => getRelationView(config.view, field))]);
|
|
742
|
+
const relationFields = /* @__PURE__ */ new Set([...Object.keys(config.relations ?? {}), ...Object.keys(config.view.fields).filter((field) => getRelationView(config.view, field))]);
|
|
739
743
|
for (const field of relationFields) {
|
|
740
744
|
const relationView = getRelationView(config.view, field);
|
|
741
745
|
if (!relationView) throw new Error(`Source ${config.view.typeName}.${field} must reference a data view relation.`);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { TRPCClient } from "@trpc/client";
|
|
2
2
|
|
|
3
|
-
//#region ../../node_modules/.pnpm/@trpc+server@11.
|
|
3
|
+
//#region ../../node_modules/.pnpm/@trpc+server@11.18.0_typescript@6.0.3/node_modules/@trpc/server/dist/index.d-D4qZxQJh.d.mts
|
|
4
4
|
//#region src/observable/types.d.ts
|
|
5
5
|
interface Unsubscribable {
|
|
6
6
|
unsubscribe(): void;
|
|
@@ -24,7 +24,7 @@ interface Observer<TValue, TError> {
|
|
|
24
24
|
type UnaryFunction<TSource, TReturn> = (source: TSource) => TReturn;
|
|
25
25
|
type OperatorFunction<TValueBefore, TErrorBefore, TValueAfter, TErrorAfter> = UnaryFunction<Subscribable<TValueBefore, TErrorBefore>, Subscribable<TValueAfter, TErrorAfter>>;
|
|
26
26
|
//#endregion
|
|
27
|
-
//#region ../../node_modules/.pnpm/@trpc+server@11.
|
|
27
|
+
//#region ../../node_modules/.pnpm/@trpc+server@11.18.0_typescript@6.0.3/node_modules/@trpc/server/dist/unstable-core-do-not-import.d-BdVSvUCr.d.mts
|
|
28
28
|
/**
|
|
29
29
|
* @public
|
|
30
30
|
*/
|
|
@@ -825,6 +825,7 @@ declare class FateClient<Roots extends FateRoots, Mutations extends FateMutation
|
|
|
825
825
|
private applyListInsert;
|
|
826
826
|
private insertIntoRootLists;
|
|
827
827
|
getTypeConfig(type: string): TypeConfig;
|
|
828
|
+
private getListNodeType;
|
|
828
829
|
executeMutation(key: string, input: unknown, select: Set<string>, options?: {
|
|
829
830
|
args?: AnyRecord;
|
|
830
831
|
plan?: SelectionPlan;
|
package/lib/vite.mjs
CHANGED
|
@@ -203,7 +203,8 @@ const createClientSource = ({ clientModule = "react-fate", moduleExports, module
|
|
|
203
203
|
const mutationResolverBlock = indentBlock(mutationResolverLines.join("\n"), 4);
|
|
204
204
|
const mutationConfigBlock = indentBlock(mutationConfigLines.join("\n"), 2);
|
|
205
205
|
const byIdBlock = indentBlock(byIdLines.join("\n"), 8);
|
|
206
|
-
const
|
|
206
|
+
const rootBlockContent = rootEntries.map((entry) => entry.value).join("\n");
|
|
207
|
+
const rootsBlock = indentBlock(rootBlockContent, 2);
|
|
207
208
|
const listsBlockContent = listLines.join("\n");
|
|
208
209
|
const listsBlock = listLines.length ? ` lists: {\n${indentBlock(listsBlockContent, 8)}\n },\n` : "";
|
|
209
210
|
const queriesBlockContent = queryLines.join("\n");
|
|
@@ -331,7 +332,7 @@ const createGraphQLClientSource = ({ clientModule, moduleExports, moduleName })
|
|
|
331
332
|
pagination: import('${clientModule}').Pagination;
|
|
332
333
|
}` : `${root.type} | null`}, '${root.type}'>('${root.type}'),`
|
|
333
334
|
}))].sort((a, b) => a.name.localeCompare(b.name));
|
|
334
|
-
const importedTypes = Array.from(new Set([
|
|
335
|
+
const importedTypes = Array.from(/* @__PURE__ */ new Set([
|
|
335
336
|
...types.map((type) => type.type),
|
|
336
337
|
...mutationEntries.map((entry) => entry.entity),
|
|
337
338
|
...graphQLConfig.mutations ? [graphQLConfigExportName] : []
|
|
@@ -447,7 +448,7 @@ const createNativeClientSource = ({ clientModule, cloudflareTransport, moduleExp
|
|
|
447
448
|
value: `'${name}': clientRoot<FateAPI['${root.kind === "list" ? "lists" : "queries"}']['${apiKey}']['output'], '${root.type}'>('${root.type}'),`
|
|
448
449
|
};
|
|
449
450
|
})].sort((a, b) => a.name.localeCompare(b.name));
|
|
450
|
-
const importedTypes = Array.from(new Set([
|
|
451
|
+
const importedTypes = Array.from(/* @__PURE__ */ new Set([
|
|
451
452
|
fateExportName === "fate" ? "fate as fateServer" : "fateServer",
|
|
452
453
|
...types.map((type) => type.type),
|
|
453
454
|
...mutationEntries.map((entry) => entry.type)
|
|
@@ -660,7 +661,7 @@ const removeIfExists = async (file) => {
|
|
|
660
661
|
};
|
|
661
662
|
const fate = (options) => {
|
|
662
663
|
const clientModule = `${options.clientModule ?? defaultClientRuntime}/client`;
|
|
663
|
-
const clientModules = new Set([defaultClientModule, clientModule]);
|
|
664
|
+
const clientModules = /* @__PURE__ */ new Set([defaultClientModule, clientModule]);
|
|
664
665
|
let config;
|
|
665
666
|
let dependencies = /* @__PURE__ */ new Set();
|
|
666
667
|
let generatedSource = null;
|
|
@@ -730,7 +731,7 @@ const fate = (options) => {
|
|
|
730
731
|
if (resolvedServerModule) dependencies.add(path.normalize(resolvedServerModule.id));
|
|
731
732
|
for (const dependency of dependencies) this.addWatchFile(dependency);
|
|
732
733
|
},
|
|
733
|
-
config: () => ({ ssr: { noExternal: [
|
|
734
|
+
config: () => ({ ssr: { noExternal: [.../* @__PURE__ */ new Set([defaultClientRuntime, options.clientModule ?? defaultClientRuntime])] } }),
|
|
734
735
|
configResolved: (resolvedConfig) => {
|
|
735
736
|
config = resolvedConfig;
|
|
736
737
|
},
|