@nkzw/fate 1.3.1 → 1.3.3

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.
Files changed (171) hide show
  1. package/docs/api/classes/FateClient.md +40 -40
  2. package/docs/api/functions/clientRoot.md +1 -1
  3. package/docs/api/functions/createClient.md +1 -1
  4. package/docs/api/functions/createGraphQLTransport.md +1 -1
  5. package/docs/api/functions/createHTTPTransport.md +1 -1
  6. package/docs/api/functions/createTRPCTransport.md +1 -1
  7. package/docs/api/functions/defer.md +1 -1
  8. package/docs/api/functions/getDeferredMetadata.md +1 -1
  9. package/docs/api/functions/getListEntries.md +1 -1
  10. package/docs/api/functions/getSelectionPlan.md +1 -1
  11. package/docs/api/functions/graphqlMutation.md +1 -1
  12. package/docs/api/functions/isDeferred.md +1 -1
  13. package/docs/api/functions/isRecord.md +1 -1
  14. package/docs/api/functions/isViewTag.md +1 -1
  15. package/docs/api/functions/liveConnectionTopic.md +1 -1
  16. package/docs/api/functions/liveEntityTopic.md +1 -1
  17. package/docs/api/functions/liveGlobalConnectionTopic.md +1 -1
  18. package/docs/api/functions/mutation.md +1 -1
  19. package/docs/api/functions/toEntityId.md +1 -1
  20. package/docs/api/functions/view.md +1 -1
  21. package/docs/api/interfaces/FateThenable.md +3 -3
  22. package/docs/api/interfaces/Transport.md +7 -7
  23. package/docs/api/server/classes/FateRequestError.md +5 -5
  24. package/docs/api/server/drizzle/functions/createDrizzleFate.md +1 -1
  25. package/docs/api/server/drizzle/functions/createDrizzleSourceAdapter.md +1 -1
  26. package/docs/api/server/drizzle/functions/createDrizzleSourceRegistry.md +1 -1
  27. package/docs/api/server/drizzle/type-aliases/DrizzleManyToManyConfig.md +1 -1
  28. package/docs/api/server/drizzle/type-aliases/DrizzleManyToManyInput.md +1 -1
  29. package/docs/api/server/drizzle/type-aliases/DrizzleQueryExtra.md +3 -3
  30. package/docs/api/server/drizzle/type-aliases/DrizzleSourceAdapter.md +9 -9
  31. package/docs/api/server/drizzle/type-aliases/DrizzleViewConfig.md +1 -1
  32. package/docs/api/server/functions/bindSourceProcedures.md +1 -1
  33. package/docs/api/server/functions/computed.md +1 -1
  34. package/docs/api/server/functions/count.md +1 -1
  35. package/docs/api/server/functions/createFateFetchHandler.md +1 -1
  36. package/docs/api/server/functions/createFateServer.md +1 -1
  37. package/docs/api/server/functions/createHonoFateHandler.md +1 -1
  38. package/docs/api/server/functions/createLiveEventBus.md +1 -1
  39. package/docs/api/server/functions/createNestedSourcePlan.md +1 -1
  40. package/docs/api/server/functions/createResolver.md +1 -1
  41. package/docs/api/server/functions/createSourcePlan.md +1 -1
  42. package/docs/api/server/functions/createSourceProcedures.md +1 -1
  43. package/docs/api/server/functions/dataView.md +1 -1
  44. package/docs/api/server/functions/field.md +1 -1
  45. package/docs/api/server/functions/getNestedSelection.md +1 -1
  46. package/docs/api/server/functions/getScopedArgs.md +1 -1
  47. package/docs/api/server/functions/hasNestedSelection.md +1 -1
  48. package/docs/api/server/functions/list.md +1 -1
  49. package/docs/api/server/functions/refetchSourceById.md +1 -1
  50. package/docs/api/server/functions/resolveSourceById.md +1 -1
  51. package/docs/api/server/functions/resolveSourceByIds.md +1 -1
  52. package/docs/api/server/functions/resolveSourceConnection.md +1 -1
  53. package/docs/api/server/functions/resolver.md +1 -1
  54. package/docs/api/server/functions/toPrismaSelect.md +1 -1
  55. package/docs/api/server/functions/withConnection.md +1 -1
  56. package/docs/api/server/prisma/functions/createPrismaFate.md +1 -1
  57. package/docs/api/server/prisma/functions/createPrismaSourceAdapter.md +1 -1
  58. package/docs/api/server/prisma/functions/createPrismaSourceRegistry.md +1 -1
  59. package/docs/api/server/prisma/functions/prismaConnectionArgs.md +1 -1
  60. package/docs/api/server/prisma/type-aliases/PrismaDelegate.md +4 -4
  61. package/docs/api/server/prisma/type-aliases/PrismaQueryExtra.md +1 -1
  62. package/docs/api/server/prisma/type-aliases/PrismaSourceAdapter.md +9 -9
  63. package/docs/api/server/prisma/type-aliases/PrismaViewConfig.md +1 -1
  64. package/docs/api/server/type-aliases/ComputedField.md +5 -5
  65. package/docs/api/server/type-aliases/ComputedSelection.md +1 -1
  66. package/docs/api/server/type-aliases/ConnectionItem.md +3 -3
  67. package/docs/api/server/type-aliases/ConnectionPagination.md +5 -5
  68. package/docs/api/server/type-aliases/ConnectionResult.md +3 -3
  69. package/docs/api/server/type-aliases/CountSelection.md +4 -4
  70. package/docs/api/server/type-aliases/CountWhere.md +1 -1
  71. package/docs/api/server/type-aliases/DataViewListOptions.md +2 -2
  72. package/docs/api/server/type-aliases/DataViewOrderBy.md +1 -1
  73. package/docs/api/server/type-aliases/DataViewOrderDirection.md +1 -1
  74. package/docs/api/server/type-aliases/DataViewResult.md +1 -1
  75. package/docs/api/server/type-aliases/Entity.md +1 -1
  76. package/docs/api/server/type-aliases/FateServer.md +5 -5
  77. package/docs/api/server/type-aliases/FateServerManifest.md +1 -1
  78. package/docs/api/server/type-aliases/FieldSelection.md +3 -3
  79. package/docs/api/server/type-aliases/LiveConnectionEventType.md +1 -1
  80. package/docs/api/server/type-aliases/LiveConnectionSourceEvent.md +1 -1
  81. package/docs/api/server/type-aliases/LiveEventBus.md +1 -1
  82. package/docs/api/server/type-aliases/LiveEventType.md +1 -1
  83. package/docs/api/server/type-aliases/LiveSourceEvent.md +1 -1
  84. package/docs/api/server/type-aliases/NativeFateAPI.md +4 -4
  85. package/docs/api/server/type-aliases/OrderDirection.md +1 -1
  86. package/docs/api/server/type-aliases/SourceConfig.md +6 -6
  87. package/docs/api/server/type-aliases/SourceDefinition.md +6 -6
  88. package/docs/api/server/type-aliases/SourceOrder.md +1 -1
  89. package/docs/api/server/type-aliases/SourceOrderField.md +3 -3
  90. package/docs/api/server/type-aliases/SourcePlan.md +1 -1
  91. package/docs/api/server/type-aliases/SourcePlanNode.md +1 -1
  92. package/docs/api/server/type-aliases/SourceRegistry.md +1 -1
  93. package/docs/api/server/type-aliases/SourceRelation.md +1 -1
  94. package/docs/api/server/type-aliases/SourceRelationConfig.md +1 -1
  95. package/docs/api/server/variables/byIdInput.md +1 -1
  96. package/docs/api/server/variables/connectionArgs.md +1 -1
  97. package/docs/api/type-aliases/ConnectionMetadata.md +1 -1
  98. package/docs/api/type-aliases/ConnectionRef.md +1 -1
  99. package/docs/api/type-aliases/Deferred.md +1 -1
  100. package/docs/api/type-aliases/DeferredMetadata.md +1 -1
  101. package/docs/api/type-aliases/DeferredSelection.md +1 -1
  102. package/docs/api/type-aliases/DeferredSnapshot.md +1 -1
  103. package/docs/api/type-aliases/Entity.md +2 -2
  104. package/docs/api/type-aliases/EntityId.md +1 -1
  105. package/docs/api/type-aliases/FateDehydratedState.md +1 -1
  106. package/docs/api/type-aliases/FateLiveConnectionEvent.md +1 -1
  107. package/docs/api/type-aliases/FateLiveEvent.md +1 -1
  108. package/docs/api/type-aliases/FateMutations.md +1 -1
  109. package/docs/api/type-aliases/FateOperation.md +1 -1
  110. package/docs/api/type-aliases/FateProtocolRequest.md +1 -1
  111. package/docs/api/type-aliases/FateProtocolResponse.md +1 -1
  112. package/docs/api/type-aliases/FateRecord.md +1 -1
  113. package/docs/api/type-aliases/FateRoots.md +1 -1
  114. package/docs/api/type-aliases/GraphQLMutationDefinition.md +1 -1
  115. package/docs/api/type-aliases/GraphQLMutationInput.md +1 -1
  116. package/docs/api/type-aliases/GraphQLMutationMap.md +1 -1
  117. package/docs/api/type-aliases/GraphQLMutationOutput.md +1 -1
  118. package/docs/api/type-aliases/GraphQLTransportOptions.md +11 -11
  119. package/docs/api/type-aliases/HydrateOptions.md +1 -1
  120. package/docs/api/type-aliases/HydrationLimits.md +1 -1
  121. package/docs/api/type-aliases/InferFateAPI.md +1 -1
  122. package/docs/api/type-aliases/List.md +1 -1
  123. package/docs/api/type-aliases/ListEntry.md +1 -1
  124. package/docs/api/type-aliases/ListItem.md +1 -1
  125. package/docs/api/type-aliases/Mask.md +1 -1
  126. package/docs/api/type-aliases/MutationDefinition.md +1 -1
  127. package/docs/api/type-aliases/MutationEntity.md +1 -1
  128. package/docs/api/type-aliases/MutationIdentifier.md +1 -1
  129. package/docs/api/type-aliases/MutationInput.md +1 -1
  130. package/docs/api/type-aliases/MutationResult.md +1 -1
  131. package/docs/api/type-aliases/NodesItem.md +1 -1
  132. package/docs/api/type-aliases/Pagination.md +5 -5
  133. package/docs/api/type-aliases/Request.md +1 -1
  134. package/docs/api/type-aliases/RequestMode.md +1 -1
  135. package/docs/api/type-aliases/RequestOptions.md +1 -1
  136. package/docs/api/type-aliases/RequestResult.md +1 -1
  137. package/docs/api/type-aliases/Selection.md +1 -1
  138. package/docs/api/type-aliases/Snapshot.md +1 -1
  139. package/docs/api/type-aliases/TypeConfig.md +4 -4
  140. package/docs/api/type-aliases/View.md +1 -1
  141. package/docs/api/type-aliases/ViewData.md +1 -1
  142. package/docs/api/type-aliases/ViewEntity.md +1 -1
  143. package/docs/api/type-aliases/ViewEntityName.md +1 -1
  144. package/docs/api/type-aliases/ViewRef.md +1 -1
  145. package/docs/api/type-aliases/ViewSelection.md +1 -1
  146. package/docs/api/type-aliases/ViewSnapshot.md +1 -1
  147. package/docs/api/type-aliases/ViewTag.md +1 -1
  148. package/docs/api/variables/ConnectionTag.md +1 -1
  149. package/docs/api/variables/DeferTag.md +1 -1
  150. package/docs/api/variables/DeferredTag.md +1 -1
  151. package/lib/{executor-Dh-MLUXc.d.mts → executor-C8HNogYG.d.mts} +1 -1
  152. package/lib/{graphqlTransport-IFgmY-Qq.mjs → graphqlTransport-DSBVS2Fq.mjs} +20 -15
  153. package/lib/{graphqlTransport-B3cbhvJX.d.mts → graphqlTransport-DskuXeUP.d.mts} +1 -1
  154. package/lib/graphqlTransport.d.mts +1 -1
  155. package/lib/graphqlTransport.mjs +1 -1
  156. package/lib/index.d.mts +4 -4
  157. package/lib/index.mjs +36 -25
  158. package/lib/{list-BrL6PD_6.d.mts → list-sI2UPhHc.d.mts} +1 -1
  159. package/lib/list.d.mts +1 -1
  160. package/lib/{liveTopics-JIDh3t3P.mjs → liveTopics-uVP0LG-Q.mjs} +1 -1
  161. package/lib/{record-BkvZwvFk.d.mts → record-CZyyeLa3.d.mts} +2 -2
  162. package/lib/server/drizzle.d.mts +2 -2
  163. package/lib/server/drizzle.mjs +43 -31
  164. package/lib/server/prisma.d.mts +2 -2
  165. package/lib/server/prisma.mjs +10 -8
  166. package/lib/server.d.mts +3 -3
  167. package/lib/server.mjs +23 -20
  168. package/lib/{sourceRouter-N9Vp0Cj6.mjs → sourceRouter-DSaADXSf.mjs} +8 -4
  169. package/lib/{transport-BjGm__3t.d.mts → transport-DhaVVq4P.d.mts} +3 -2
  170. package/lib/vite.mjs +6 -5
  171. package/package.json +4 -4
@@ -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-N9Vp0Cj6.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-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 childConfig = getSourceConfig(resolveSource(sourceRelation.source));
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 childConfig = getSourceConfig(resolveSource(sourceRelation.source));
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 hydrated = await hydrateRows(await queryRows({
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
- }), relationNode, ctx);
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: await hydrateRows(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
- }), 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: await hydrateRows(await queryManyToManyPage({
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 hydrated = await hydrateRows(await getDb(ctx).select({
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)), relationNode, ctx);
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 childByKey = mapByField(await hydrateRows(childKeys.length ? await queryRows({
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
- }) : [], relationNode, ctx), sourceRelation.foreignKey);
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
- return reorderByIds(ids, await hydrateRows(await queryRows({
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
- }), plan.root, ctx));
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
- return procedures(procedureInput && typeof procedureInput === "object" && "view" in procedureInput ? {
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,
@@ -1,5 +1,5 @@
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";
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 = {
@@ -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-N9Vp0Cj6.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-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: items.flatMap((item) => {
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
- return procedures(procedureInput && typeof procedureInput === "object" && "view" in procedureInput ? {
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-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";
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-JIDh3t3P.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-N9Vp0Cj6.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-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
- registerSourceByType(sources.getSource(view));
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, 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
- }), 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, event.type === "delete" ? null : await resolveLiveSourceData({
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
- assignDependencyPath(ensureRelationSelect(select, node.path), selection.path);
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)) mergeObject(ensureRelationSelect(select, node.path), 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.17.0_typescript@6.0.3/node_modules/@trpc/server/dist/index.d-D4qZxQJh.d.mts
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.17.0_typescript@6.0.3/node_modules/@trpc/server/dist/unstable-core-do-not-import.d-BdVSvUCr.d.mts
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 rootsBlock = indentBlock(rootEntries.map((entry) => entry.value).join("\n"), 2);
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: [...new Set([defaultClientRuntime, options.clientModule ?? defaultClientRuntime])] } }),
734
+ config: () => ({ ssr: { noExternal: [.../* @__PURE__ */ new Set([defaultClientRuntime, options.clientModule ?? defaultClientRuntime])] } }),
734
735
  configResolved: (resolvedConfig) => {
735
736
  config = resolvedConfig;
736
737
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nkzw/fate",
3
- "version": "1.3.1",
3
+ "version": "1.3.3",
4
4
  "description": "fate is a modern data client for React.",
5
5
  "homepage": "https://github.com/nkzw-tech/fate",
6
6
  "license": "MIT",
@@ -69,10 +69,10 @@
69
69
  "zod": "^4.4.3"
70
70
  },
71
71
  "devDependencies": {
72
- "@trpc/client": "^11.17.0",
73
- "@trpc/server": "^11.17.0",
72
+ "@trpc/client": "^11.18.0",
73
+ "@trpc/server": "^11.18.0",
74
74
  "drizzle-orm": "^0.45.2",
75
- "vite": "^8.0.16"
75
+ "vite": "npm:@voidzero-dev/vite-plus-core@0.2.4"
76
76
  },
77
77
  "peerDependencies": {
78
78
  "@trpc/client": "^11.6.0",