kitcn 0.17.1 → 0.17.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.
@@ -1,4 +1,4 @@
1
- import { $ as GenericOrmCtx$1, $n as unique, $r as endsWith, $t as ManyConfig, A as ConvexDateMode, An as ConvexRankIndexBuilder, Ar as ReturningResult, At as MigrationManifestEntry, B as ConvexBytesBuilderInitial, Bn as rankIndex, Br as OrmSchemaRelations, Bt as defineMigration, C as ConvexNumberBuilderInitial, Ci as ColumnBuilderWithTableName, Cn as RlsRole, Cr as MutationReturning, Ct as MigrationStatusArgs, D as id, Di as IsPrimaryKey, Dn as ConvexAggregateIndexBuilderOn, Dr as PaginatedResult, Dt as MigrationDoc, E as ConvexIdBuilderInitial, Ei as HasDefault, En as ConvexAggregateIndexBuilder, Er as OrderDirection, Et as MigrationDirection, F as custom, Fn as ConvexVectorIndexBuilder, Fr as unsetToken, Ft as MigrationStateMap, G as ConvexBigIntBuilder, Gn as ConvexCheckConfig, Gr as ExpressionVisitor, Gt as OrmReader$1, H as ConvexBooleanBuilder, Hn as uniqueIndex, Hr as TableName, Ht as detectMigrationDrift, I as json, In as ConvexVectorIndexBuilderOn, Ir as Brand, It as MigrationStep, J as CountBackfillChunkArgs, Jn as ConvexUniqueConstraintBuilder, Jr as LogicalExpression, Jt as RlsMode, K as ConvexBigIntBuilderInitial, Kn as ConvexForeignKeyBuilder, Kr as FieldReference, Kt as OrmWriter$1, L as objectOf, Ln as ConvexVectorIndexConfig, Lr as Columns, Lt as MigrationTableName, M as ConvexCustomBuilder, Mn as ConvexSearchIndexBuilder, Mr as UpdateSet, Mt as MigrationPlan, N as ConvexCustomBuilderInitial, Nn as ConvexSearchIndexBuilderOn, Nr as VectorQueryConfig, Nt as MigrationRunStatus, O as ConvexDateBuilder, Oi as IsUnique, On as ConvexIndexBuilder, Or as PredicateWhereIndexConfig, Ot as MigrationDocContext, P as arrayOf, Pn as ConvexSearchIndexConfig, Pr as VectorSearchProvider, Pt as MigrationSet, Q as GenericOrm$1, Qn as foreignKey, Qr as contains, Qt as ExtractTablesWithRelations, R as unionOf, Rn as aggregateIndex, Rr as OrmSchemaExtensionTables, Rt as MigrationWriteMode, S as ConvexNumberBuilder, Si as ColumnBuilderTypeConfig, Sn as rlsPolicy, Sr as MutationResult, St as MigrationRunChunkArgs, T as ConvexIdBuilder, Ti as DrizzleEntity, Tn as rlsRole, Tr as OrderByClause, Tt as MigrationDefinition, U as ConvexBooleanBuilderInitial, Un as vectorIndex, Ur as SystemFields, Ut as DatabaseWithMutations, V as bytes, Vn as searchIndex, Vr as OrmSchemaTriggers, Vt as defineMigrationSet, W as boolean, Wn as ConvexCheckBuilder, Wr as BinaryExpression, Wt as DatabaseWithQuery, X as CountBackfillStatusArgs, Xn as ConvexUniqueConstraintConfig, Xr as and, Xt as extractRelationsConfig, Y as CountBackfillKickoffArgs, Yn as ConvexUniqueConstraintBuilderOn, Yr as UnaryExpression, Yt as EdgeMetadata, Z as CreateOrmOptions, Zn as check, Zr as between, Zt as ExtractTablesFromSchema, _ as ConvexTimestampMode, _i as startsWith, _n as deletion, _r as MutationExecuteConfig, _t as OrmTriggerContext, a as requireSchemaRelations, ai as inArray, an as TablesRelationalConfig, ar as AggregateResult, at as OrmWriterCtx, b as ConvexTextEnumBuilderInitial, bi as ColumnBuilderBaseConfig, bn as RlsPolicyConfig, br as MutationPaginateConfig, bt as MigrationCancelArgs, c as TableConfigResult, ci as isNull, cn as ConvexDeletionBuilder, cr as CountConfig, ct as ScheduledMutationBatchArgs, d as OrmNotFoundError, di as lte, dn as ConvexTableWithColumns, dr as FilterOperators, dt as scheduledDeleteFactory, ei as eq, en as OneConfig, er as ConvexTextBuilder, et as OrmApiResult, f as ConvexVectorBuilder, fi as ne, fn as DiscriminatorBuilderConfig, fr as GetColumnData, ft as SchemaExtension, g as ConvexTimestampBuilderInitial, gi as or, gn as convexTable, gr as InsertValue, gt as OrmTriggerChange, h as ConvexTimestampBuilder, hi as notInArray, hn as TableConfig, hr as InferSelectModel, ht as OrmTableTriggers, i as getSchemaTriggers, ii as ilike, in as TableRelationalConfig, ir as AggregateFieldValue, it as OrmReaderCtx, j as date, jn as ConvexRankIndexBuilderOn, jr as ReturningSelection, jt as MigrationMigrateOne, k as ConvexDateBuilderInitial, ki as NotNull, kn as ConvexIndexBuilderOn, kr as ReturningAll, kt as MigrationDriftIssue, l as getTableColumns, li as like, ln as ConvexDeletionConfig, lr as CountResult, lt as scheduledMutationBatchFactory, m as vector, mi as notBetween, mn as OrmLifecycleOperation, mr as InferModelFromColumns, mt as OrmBeforeResult, n as defineSchema, ni as gt, nn as RelationsBuilderColumnBase, nr as text, nt as OrmClientWithApi$1, o as asc, oi as isFieldReference, on as defineRelations, or as BuildQueryResult, ot as ResolveOrmSchema, p as ConvexVectorBuilderInitial, pi as not, pn as OrmLifecycleChange, pr as InferInsertModel, pt as defineSchemaExtension, q as bigint, qn as ConvexForeignKeyConfig, qr as FilterExpression, qt as RlsContext, r as getSchemaRelations, ri as gte, rn as RelationsBuilderColumnConfig, rr as AggregateConfig, rt as OrmFunctions, s as desc, si as isNotNull, sn as defineRelationsPart, sr as BuildRelationResult, st as createOrm, t as WhereClauseResult, ti as fieldRef, tn as RelationsBuilder, tr as ConvexTextBuilderInitial, tt as OrmClientBase$1, u as getTableConfig, ui as lt, un as ConvexTable, ur as DBQueryConfig, ut as ScheduledDeleteArgs, v as timestamp, vi as AnyColumn, vn as discriminator, vr as MutationExecuteResult, vt as OrmTriggers, w as integer, wi as ColumnDataType, wn as RlsRoleConfig, wr as MutationRunMode, wt as MigrationAppliedState, x as textEnum, xi as ColumnBuilderRuntimeConfig, xn as RlsPolicyToOption, xr as MutationPaginatedResult, xt as MigrationRunArgs, y as ConvexTextEnumBuilder, yi as ColumnBuilder, yn as RlsPolicy, yr as MutationExecutionMode, yt as defineTriggers, z as ConvexBytesBuilder, zn as index, zr as OrmSchemaExtensions, zt as buildMigrationPlan } from "../where-clause-compiler-BRhLW1dp.js";
1
+ import { $ as GenericOrmCtx$1, $n as unique, $r as endsWith, $t as ManyConfig, A as ConvexDateMode, An as ConvexRankIndexBuilder, Ar as ReturningResult, At as MigrationManifestEntry, B as ConvexBytesBuilderInitial, Bn as rankIndex, Br as OrmSchemaRelations, Bt as defineMigration, C as ConvexNumberBuilderInitial, Ci as ColumnBuilderWithTableName, Cn as RlsRole, Cr as MutationReturning, Ct as MigrationStatusArgs, D as id, Di as IsPrimaryKey, Dn as ConvexAggregateIndexBuilderOn, Dr as PaginatedResult, Dt as MigrationDoc, E as ConvexIdBuilderInitial, Ei as HasDefault, En as ConvexAggregateIndexBuilder, Er as OrderDirection, Et as MigrationDirection, F as custom, Fn as ConvexVectorIndexBuilder, Fr as unsetToken, Ft as MigrationStateMap, G as ConvexBigIntBuilder, Gn as ConvexCheckConfig, Gr as ExpressionVisitor, Gt as OrmReader$1, H as ConvexBooleanBuilder, Hn as uniqueIndex, Hr as TableName, Ht as detectMigrationDrift, I as json, In as ConvexVectorIndexBuilderOn, Ir as Brand, It as MigrationStep, J as CountBackfillChunkArgs, Jn as ConvexUniqueConstraintBuilder, Jr as LogicalExpression, Jt as RlsMode, K as ConvexBigIntBuilderInitial, Kn as ConvexForeignKeyBuilder, Kr as FieldReference, Kt as OrmWriter$1, L as objectOf, Ln as ConvexVectorIndexConfig, Lr as Columns, Lt as MigrationTableName, M as ConvexCustomBuilder, Mn as ConvexSearchIndexBuilder, Mr as UpdateSet, Mt as MigrationPlan, N as ConvexCustomBuilderInitial, Nn as ConvexSearchIndexBuilderOn, Nr as VectorQueryConfig, Nt as MigrationRunStatus, O as ConvexDateBuilder, Oi as IsUnique, On as ConvexIndexBuilder, Or as PredicateWhereIndexConfig, Ot as MigrationDocContext, P as arrayOf, Pn as ConvexSearchIndexConfig, Pr as VectorSearchProvider, Pt as MigrationSet, Q as GenericOrm$1, Qn as foreignKey, Qr as contains, Qt as ExtractTablesWithRelations, R as unionOf, Rn as aggregateIndex, Rr as OrmSchemaExtensionTables, Rt as MigrationWriteMode, S as ConvexNumberBuilder, Si as ColumnBuilderTypeConfig, Sn as rlsPolicy, Sr as MutationResult, St as MigrationRunChunkArgs, T as ConvexIdBuilder, Ti as DrizzleEntity, Tn as rlsRole, Tr as OrderByClause, Tt as MigrationDefinition, U as ConvexBooleanBuilderInitial, Un as vectorIndex, Ur as SystemFields, Ut as DatabaseWithMutations, V as bytes, Vn as searchIndex, Vr as OrmSchemaTriggers, Vt as defineMigrationSet, W as boolean, Wn as ConvexCheckBuilder, Wr as BinaryExpression, Wt as DatabaseWithQuery, X as CountBackfillStatusArgs, Xn as ConvexUniqueConstraintConfig, Xr as and, Xt as extractRelationsConfig, Y as CountBackfillKickoffArgs, Yn as ConvexUniqueConstraintBuilderOn, Yr as UnaryExpression, Yt as EdgeMetadata, Z as CreateOrmOptions, Zn as check, Zr as between, Zt as ExtractTablesFromSchema, _ as ConvexTimestampMode, _i as startsWith, _n as deletion, _r as MutationExecuteConfig, _t as OrmTriggerContext, a as requireSchemaRelations, ai as inArray, an as TablesRelationalConfig, ar as AggregateResult, at as OrmWriterCtx, b as ConvexTextEnumBuilderInitial, bi as ColumnBuilderBaseConfig, bn as RlsPolicyConfig, br as MutationPaginateConfig, bt as MigrationCancelArgs, c as TableConfigResult, ci as isNull, cn as ConvexDeletionBuilder, cr as CountConfig, ct as ScheduledMutationBatchArgs, d as OrmNotFoundError, di as lte, dn as ConvexTableWithColumns, dr as FilterOperators, dt as scheduledDeleteFactory, ei as eq, en as OneConfig, er as ConvexTextBuilder, et as OrmApiResult, f as ConvexVectorBuilder, fi as ne, fn as DiscriminatorBuilderConfig, fr as GetColumnData, ft as SchemaExtension, g as ConvexTimestampBuilderInitial, gi as or, gn as convexTable, gr as InsertValue, gt as OrmTriggerChange, h as ConvexTimestampBuilder, hi as notInArray, hn as TableConfig, hr as InferSelectModel, ht as OrmTableTriggers, i as getSchemaTriggers, ii as ilike, in as TableRelationalConfig, ir as AggregateFieldValue, it as OrmReaderCtx, j as date, jn as ConvexRankIndexBuilderOn, jr as ReturningSelection, jt as MigrationMigrateOne, k as ConvexDateBuilderInitial, ki as NotNull, kn as ConvexIndexBuilderOn, kr as ReturningAll, kt as MigrationDriftIssue, l as getTableColumns, li as like, ln as ConvexDeletionConfig, lr as CountResult, lt as scheduledMutationBatchFactory, m as vector, mi as notBetween, mn as OrmLifecycleOperation, mr as InferModelFromColumns, mt as OrmBeforeResult, n as defineSchema, ni as gt, nn as RelationsBuilderColumnBase, nr as text, nt as OrmClientWithApi$1, o as asc, oi as isFieldReference, on as defineRelations, or as BuildQueryResult, ot as ResolveOrmSchema, p as ConvexVectorBuilderInitial, pi as not, pn as OrmLifecycleChange, pr as InferInsertModel, pt as defineSchemaExtension, q as bigint, qn as ConvexForeignKeyConfig, qr as FilterExpression, qt as RlsContext, r as getSchemaRelations, ri as gte, rn as RelationsBuilderColumnConfig, rr as AggregateConfig, rt as OrmFunctions, s as desc, si as isNotNull, sn as defineRelationsPart, sr as BuildRelationResult, st as createOrm, t as WhereClauseResult, ti as fieldRef, tn as RelationsBuilder, tr as ConvexTextBuilderInitial, tt as OrmClientBase$1, u as getTableConfig, ui as lt, un as ConvexTable, ur as DBQueryConfig, ut as ScheduledDeleteArgs, v as timestamp, vi as AnyColumn, vn as discriminator, vr as MutationExecuteResult, vt as OrmTriggers, w as integer, wi as ColumnDataType, wn as RlsRoleConfig, wr as MutationRunMode, wt as MigrationAppliedState, x as textEnum, xi as ColumnBuilderRuntimeConfig, xn as RlsPolicyToOption, xr as MutationPaginatedResult, xt as MigrationRunArgs, y as ConvexTextEnumBuilder, yi as ColumnBuilder, yn as RlsPolicy, yr as MutationExecutionMode, yt as defineTriggers, z as ConvexBytesBuilder, zn as index, zr as OrmSchemaExtensions, zt as buildMigrationPlan } from "../where-clause-compiler-BgEc0GdS.js";
2
2
  import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-BhsByJeg.js";
3
3
  import { a as QueryCtxWithPreferredOrmQueryTable, i as QueryCtxWithOrmQueryTable, n as LookupByIdResultByCtx, o as getByIdWithOrmQueryFallback, r as QueryCtxWithOptionalOrmQueryTable, t as DocByCtx } from "../query-context-CNo9ffvI.js";
4
4
  import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchemaDefinition } from "convex/server";
@@ -1,10 +1,10 @@
1
1
  import { getFunctionName } from "convex/server";
2
- import { Show, createContext, createEffect, createMemo, createSignal, on, onCleanup, onMount, useContext } from "solid-js";
2
+ import { Show, createComputed, createContext, createEffect, createMemo, createRenderEffect, createSignal, on, onCleanup, onMount, useContext } from "solid-js";
3
3
  import { createComponent, memo } from "solid-js/web";
4
4
  import { createStore } from "solid-js/store";
5
- import { notifyManager, skipToken, useQueries, useQueryClient } from "@tanstack/solid-query";
5
+ import { notifyManager, skipToken, useQueryClient } from "@tanstack/solid-query";
6
6
  import { ConvexClient, ConvexHttpClient } from "convex/browser";
7
- import { hashKey } from "@tanstack/query-core";
7
+ import { QueriesObserver, hashKey } from "@tanstack/query-core";
8
8
  import { convexToJson } from "convex/values";
9
9
 
10
10
  //#region src/crpc/error.ts
@@ -2504,6 +2504,42 @@ const getConvexQueryClientSingleton = ({ authStore, convex, queryClient, symbolK
2504
2504
  //#region src/internal/pagination.ts
2505
2505
  const shouldSplitPaginationPage = (page, initialNumItems) => Boolean(page.splitCursor) && (page.pageStatus === "SplitRecommended" || page.pageStatus === "SplitRequired" || initialNumItems !== void 0 && page.page.length > initialNumItems * 2);
2506
2506
 
2507
+ //#endregion
2508
+ //#region src/solid/create-queries-results.ts
2509
+ /**
2510
+ * Subscribe a reactive list of queries and expose the raw observer results.
2511
+ *
2512
+ * Solid Query's `useQueries` cannot back an aggregate result: it feeds the
2513
+ * `combine` output straight into `createStore` and then calls `.map()` on it,
2514
+ * so any non-array aggregate throws `state.map is not a function` while the
2515
+ * component is still setting up. It also routes `.data` through
2516
+ * `createResource`, which suspends the nearest boundary for as long as a query
2517
+ * is in flight.
2518
+ *
2519
+ * Driving `QueriesObserver` directly keeps every entry a plain
2520
+ * `QueryObserverResult` - the same value the React port aggregates - and leaves
2521
+ * aggregation to the caller.
2522
+ *
2523
+ * @param queries Reactive list of query options.
2524
+ * @returns Accessor for the raw observer results, in query order.
2525
+ */
2526
+ function createQueriesResults(queries) {
2527
+ const queryClient = useQueryClient();
2528
+ const defaulted = () => queries().map((options) => ({
2529
+ ...queryClient.defaultQueryOptions(options),
2530
+ _optimisticResults: "optimistic"
2531
+ }));
2532
+ const observer = new QueriesObserver(queryClient, defaulted());
2533
+ const [results, setResults] = createSignal(observer.getCurrentResult(), { equals: false });
2534
+ createComputed(() => {
2535
+ const next = defaulted();
2536
+ observer.setQueries(next);
2537
+ setResults(observer.getOptimisticResult(next, void 0)[0]);
2538
+ });
2539
+ onCleanup(observer.subscribe((next) => setResults(next)));
2540
+ return results;
2541
+ }
2542
+
2507
2543
  //#endregion
2508
2544
  //#region src/solid/use-infinite-query.ts
2509
2545
  const PAGINATION_KEY_PREFIX = "__pagination__";
@@ -2516,6 +2552,59 @@ const getOrCreatePaginationId = (storeKey) => {
2516
2552
  paginationIdStore.set(storeKey, newId);
2517
2553
  return newId;
2518
2554
  };
2555
+ /** Read the identity of a Convex document, tolerating `id` and `_id` shapes */
2556
+ const getItemId = (item) => {
2557
+ const doc = item;
2558
+ return doc?._id || doc?.id;
2559
+ };
2560
+ /**
2561
+ * Fold the per-page observer results into one pagination-shaped aggregate.
2562
+ * Pure: same inputs always produce the same output, so it is safe to re-run
2563
+ * inside a reactive derivation.
2564
+ */
2565
+ const aggregatePages = (results, hasPlaceholderData) => {
2566
+ const allItems = [];
2567
+ const pages = [];
2568
+ const seenIds = /* @__PURE__ */ new Set();
2569
+ let lastPage;
2570
+ let status = "LoadingFirstPage";
2571
+ for (let i = 0; i < results.length; i++) {
2572
+ const pageQuery = results[i];
2573
+ if (pageQuery.isLoading || pageQuery.data === void 0) {
2574
+ status = i === 0 ? "LoadingFirstPage" : "LoadingMore";
2575
+ break;
2576
+ }
2577
+ const page = pageQuery.data;
2578
+ lastPage = page;
2579
+ pages.push(page.page);
2580
+ for (const item of page.page) {
2581
+ const id = getItemId(item);
2582
+ if (id && seenIds.has(id)) continue;
2583
+ if (id) seenIds.add(id);
2584
+ allItems.push(item);
2585
+ }
2586
+ status = page.isDone ? "Exhausted" : "CanLoadMore";
2587
+ }
2588
+ const firstPage = results.length > 0 ? results[0] : void 0;
2589
+ const isPlaceholderData = firstPage ? firstPage.isPlaceholderData : hasPlaceholderData;
2590
+ const isFetching = results.some((r) => r.isFetching);
2591
+ const error = results.find((r) => r.isError)?.error ?? null;
2592
+ return {
2593
+ data: allItems,
2594
+ dataUpdatedAt: Math.max(...results.map((r) => r.dataUpdatedAt)),
2595
+ error,
2596
+ failureReason: error,
2597
+ isError: results.some((r) => r.isError),
2598
+ isFetchNextPageError: results.length > 1 && (results.at(-1)?.isError ?? false),
2599
+ isFetching,
2600
+ isLoading: status === "LoadingFirstPage",
2601
+ isPlaceholderData,
2602
+ isRefetching: isFetching && allItems.length > 0 && !isPlaceholderData,
2603
+ lastPage,
2604
+ pages,
2605
+ status
2606
+ };
2607
+ };
2519
2608
  /** Build a unique key for recovery attempt detection */
2520
2609
  const buildRecoveryKey = (pageKeys, page0Cursor, page0UpdatedAt) => JSON.stringify({
2521
2610
  pageKeys,
@@ -2531,26 +2620,27 @@ const buildRecoveryKey = (pageKeys, page0Cursor, page0UpdatedAt) => JSON.stringi
2531
2620
  * This hook detects this pattern and creates a recovery page that fetches
2532
2621
  * enough items to cover the lost pages, preserving the user's scroll position.
2533
2622
  */
2534
- const useStaleCursorRecovery = ({ argsObject, combined, limit, setState, state }) => {
2623
+ const useStaleCursorRecovery = ({ argsObject, combined, limit, pageResults, setState, state }) => {
2535
2624
  createEffect(on([
2536
2625
  () => combined.isFetchNextPageError,
2537
- () => combined._rawResults,
2626
+ pageResults,
2538
2627
  () => state().pageKeys,
2539
2628
  () => state().queries,
2540
2629
  () => state().autoRecoveryAttempted,
2541
2630
  argsObject
2542
2631
  ], () => {
2543
2632
  if (!combined.isFetchNextPageError) return;
2544
- const page0Result = combined._rawResults[0];
2633
+ const results = pageResults();
2634
+ const page0Result = results[0];
2545
2635
  const page0Data = page0Result?.data;
2546
2636
  const page0UpdatedAt = page0Result?.dataUpdatedAt ?? 0;
2547
2637
  const hasPage0Data = page0Data !== void 0 && !page0Result?.isError;
2548
- const hasSubsequentErrors = combined._rawResults.slice(1).some((q) => q?.isError && !q?.isFetching);
2638
+ const hasSubsequentErrors = results.slice(1).some((q) => q?.isError && !q?.isFetching);
2549
2639
  if (!hasPage0Data || !hasSubsequentErrors || !page0Data?.continueCursor) return;
2550
2640
  const currentState = state();
2551
2641
  const recoveryKey = buildRecoveryKey(currentState.pageKeys, page0Data.continueCursor, page0UpdatedAt);
2552
2642
  if (currentState.autoRecoveryAttempted === recoveryKey) return;
2553
- const erroredPageKeys = currentState.pageKeys.filter((_, i) => i > 0 && combined._rawResults[i]?.isError);
2643
+ const erroredPageKeys = currentState.pageKeys.filter((_, i) => i > 0 && results[i]?.isError);
2554
2644
  const itemsToRecover = erroredPageKeys.reduce((sum, key) => {
2555
2645
  return sum + (currentState.queries[key]?.args?.limit ?? limit ?? 20);
2556
2646
  }, 0);
@@ -2711,66 +2801,27 @@ const useInfiniteQueryInternal = (query, args, options) => {
2711
2801
  } } : {}
2712
2802
  };
2713
2803
  }));
2714
- const combined = useQueries(() => ({
2715
- queries: tanstackQueries(),
2716
- combine: (results) => {
2717
- const allItems = [];
2718
- const pages = [];
2719
- const seenIds = /* @__PURE__ */ new Set();
2720
- let lastPage;
2721
- let paginationStatus = "LoadingFirstPage";
2722
- for (let i = 0; i < results.length; i++) {
2723
- const pageQuery = results[i];
2724
- if (pageQuery.isLoading || pageQuery.data === void 0) {
2725
- paginationStatus = i === 0 ? "LoadingFirstPage" : "LoadingMore";
2726
- break;
2727
- }
2728
- const page = pageQuery.data;
2729
- lastPage = page;
2730
- pages.push(page.page);
2731
- for (const item of page.page) {
2732
- const id = item._id || item.id;
2733
- if (id && seenIds.has(id)) continue;
2734
- if (id) seenIds.add(id);
2735
- allItems.push(item);
2736
- }
2737
- paginationStatus = page.isDone ? "Exhausted" : "CanLoadMore";
2738
- }
2739
- const isPlaceholderData = results[0]?.isPlaceholderData ?? !!placeholderData;
2740
- const isFetching = results.some((r) => r.isFetching);
2741
- return {
2742
- data: allItems,
2743
- dataUpdatedAt: Math.max(...results.map((r) => r.dataUpdatedAt ?? 0)),
2744
- lastPage,
2745
- pages,
2746
- status: paginationStatus,
2747
- error: results.find((r) => r.isError)?.error ?? null,
2748
- isError: results.some((r) => r.isError),
2749
- isFetching,
2750
- isFetchNextPageError: results.length > 1 && (results.at(-1)?.isError ?? false),
2751
- isPlaceholderData,
2752
- isRefetching: isFetching && allItems.length > 0 && !isPlaceholderData,
2753
- isLoading: paginationStatus === "LoadingFirstPage",
2754
- failureReason: results.find((r) => r.isError)?.error ?? null,
2755
- _rawResults: results
2756
- };
2757
- }
2758
- }));
2804
+ const pageResults = createQueriesResults(() => tanstackQueries());
2805
+ const derive = () => aggregatePages(pageResults(), !!placeholderData);
2806
+ const [combined, setCombined] = createStore(derive());
2807
+ createRenderEffect(() => setCombined(derive()));
2759
2808
  useStaleCursorRecovery({
2760
2809
  argsObject,
2761
2810
  combined,
2762
2811
  limit,
2812
+ pageResults,
2763
2813
  setState,
2764
2814
  state
2765
2815
  });
2766
2816
  createEffect(on([
2767
- () => combined._rawResults,
2817
+ pageResults,
2768
2818
  () => state().pageKeys,
2769
2819
  () => state().queries,
2770
2820
  argsObject
2771
2821
  ], () => {
2772
- for (let i = 0; i < combined._rawResults.length; i++) {
2773
- const pageQuery = combined._rawResults[i];
2822
+ const results = pageResults();
2823
+ for (let i = 0; i < results.length; i++) {
2824
+ const pageQuery = results[i];
2774
2825
  if (pageQuery.data) {
2775
2826
  const page = pageQuery.data;
2776
2827
  const pageKey = state().pageKeys[i];
package/dist/watcher.mjs CHANGED
@@ -1,12 +1,24 @@
1
1
  #!/usr/bin/env node
2
- import { At as PARSE_SNAPSHOT_SUFFIX, Dt as generateMeta, F as resolveRunDeps, Ot as getConvexConfig, j as resolveConfiguredBackend, kt as logger, q as withLocalCodegenEnv } from "./backend-core-KwJ5FZgj.mjs";
2
+ import { a as generateMeta, c as PARSE_SNAPSHOT_SUFFIX, i as resolveConfiguredBackend, n as withLocalCodegenEnv, o as getConvexConfig, r as loadCliConfig, s as logger } from "./local-env-fAYvoOfl.mjs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
6
6
  //#region src/cli/watcher.ts
7
+ function getConvexRoot(functionsDir) {
8
+ const projectDir = path.resolve(process.cwd());
9
+ const relativeFunctionsDir = path.relative(projectDir, functionsDir);
10
+ return relativeFunctionsDir.includes(path.sep) && relativeFunctionsDir !== ".." && !relativeFunctionsDir.startsWith(`..${path.sep}`) && !path.isAbsolute(relativeFunctionsDir) ? path.dirname(functionsDir) : functionsDir;
11
+ }
7
12
  function getWatchRoots(functionsDir) {
8
- const convexDir = path.dirname(functionsDir);
9
- return [functionsDir, path.join(convexDir, "routers")];
13
+ const functions = path.resolve(functionsDir);
14
+ const convexRoot = getConvexRoot(functions);
15
+ const roots = [
16
+ functions,
17
+ path.join(convexRoot, "routers"),
18
+ path.join(convexRoot, "lib"),
19
+ path.join(convexRoot, "shared")
20
+ ];
21
+ return roots.filter((root, index) => roots.indexOf(root) === index && !roots.some((other) => root.startsWith(`${other}${path.sep}`)));
10
22
  }
11
23
  function parseWatcherBackendEnv(value) {
12
24
  if (value === "convex" || value === "concave") return value;
@@ -47,10 +59,9 @@ function shouldIgnoreWatchPath(watchedPath, functionsDir, outputFile) {
47
59
  return normalizedPath.endsWith(".runtime.ts") || normalizedPath.endsWith(PARSE_SNAPSHOT_SUFFIX);
48
60
  }
49
61
  async function runWatcherCodegen(params, deps = {}) {
50
- const resolveRunDepsFn = deps.resolveRunDeps ?? resolveRunDeps;
51
62
  const resolveConfiguredBackendFn = deps.resolveConfiguredBackendFn ?? resolveConfiguredBackend;
52
- const { execa: execaFn, generateMeta: generateMetaFn, loadCliConfig: loadCliConfigFn } = resolveRunDepsFn();
53
- const config = loadCliConfigFn(params.configPath);
63
+ const generateMetaFn = deps.generateMeta ?? generateMeta;
64
+ const config = (deps.loadCliConfig ?? loadCliConfig)(params.configPath);
54
65
  const backend = resolveConfiguredBackendFn({
55
66
  backendArg: params.backendArg,
56
67
  config
@@ -78,7 +89,7 @@ async function runWatcherCodegen(params, deps = {}) {
78
89
  if (params.sharedDir) args.push("--api", params.sharedDir);
79
90
  if (params.configPath) args.push("--config", params.configPath);
80
91
  if (params.debug) args.push("--debug");
81
- const result = await execaFn(runtime, args, {
92
+ const result = await (deps.execa ?? (await import("execa")).execa)(runtime, args, {
82
93
  cwd: process.cwd(),
83
94
  reject: false,
84
95
  stdio: "pipe"
@@ -4292,19 +4292,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4292
4292
  readonly aggregate_state: ConvexTableWithColumns<{
4293
4293
  name: "aggregate_state";
4294
4294
  columns: {
4295
- status: ConvexTextBuilderInitial<""> & {
4296
- _: {
4297
- notNull: true;
4298
- };
4299
- } & {
4300
- _: {
4301
- tableName: "aggregate_state";
4302
- };
4303
- } & {
4304
- _: {
4305
- fieldName: "status";
4306
- };
4307
- };
4308
4295
  kind: ConvexTextBuilderInitial<""> & {
4309
4296
  _: {
4310
4297
  notNull: true;
@@ -4392,6 +4379,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4392
4379
  fieldName: "metricDefinitionHash";
4393
4380
  };
4394
4381
  };
4382
+ status: ConvexTextBuilderInitial<""> & {
4383
+ _: {
4384
+ notNull: true;
4385
+ };
4386
+ } & {
4387
+ _: {
4388
+ tableName: "aggregate_state";
4389
+ };
4390
+ } & {
4391
+ _: {
4392
+ fieldName: "status";
4393
+ };
4394
+ };
4395
4395
  processed: ConvexNumberBuilderInitial<""> & {
4396
4396
  _: {
4397
4397
  notNull: true;
@@ -4446,38 +4446,38 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4446
4446
  readonly migration_state: ConvexTableWithColumns<{
4447
4447
  name: "migration_state";
4448
4448
  columns: {
4449
- status: ConvexTextBuilderInitial<""> & {
4450
- _: {
4451
- notNull: true;
4452
- };
4453
- } & {
4449
+ cursor: ConvexTextBuilderInitial<""> & {
4454
4450
  _: {
4455
4451
  tableName: "migration_state";
4456
4452
  };
4457
4453
  } & {
4458
4454
  _: {
4459
- fieldName: "status";
4455
+ fieldName: "cursor";
4460
4456
  };
4461
4457
  };
4462
- cursor: ConvexTextBuilderInitial<""> & {
4458
+ direction: ConvexTextBuilderInitial<""> & {
4463
4459
  _: {
4464
4460
  tableName: "migration_state";
4465
4461
  };
4466
4462
  } & {
4467
4463
  _: {
4468
- fieldName: "cursor";
4464
+ fieldName: "direction";
4469
4465
  };
4470
4466
  };
4471
- direction: ConvexTextBuilderInitial<""> & {
4467
+ updatedAt: ConvexNumberBuilderInitial<""> & {
4468
+ _: {
4469
+ notNull: true;
4470
+ };
4471
+ } & {
4472
4472
  _: {
4473
4473
  tableName: "migration_state";
4474
4474
  };
4475
4475
  } & {
4476
4476
  _: {
4477
- fieldName: "direction";
4477
+ fieldName: "updatedAt";
4478
4478
  };
4479
4479
  };
4480
- updatedAt: ConvexNumberBuilderInitial<""> & {
4480
+ status: ConvexTextBuilderInitial<""> & {
4481
4481
  _: {
4482
4482
  notNull: true;
4483
4483
  };
@@ -4487,7 +4487,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4487
4487
  };
4488
4488
  } & {
4489
4489
  _: {
4490
- fieldName: "updatedAt";
4490
+ fieldName: "status";
4491
4491
  };
4492
4492
  };
4493
4493
  processed: ConvexNumberBuilderInitial<""> & {
@@ -4600,7 +4600,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4600
4600
  readonly migration_run: ConvexTableWithColumns<{
4601
4601
  name: "migration_run";
4602
4602
  columns: {
4603
- status: ConvexTextBuilderInitial<""> & {
4603
+ direction: ConvexTextBuilderInitial<""> & {
4604
4604
  _: {
4605
4605
  notNull: true;
4606
4606
  };
@@ -4610,10 +4610,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4610
4610
  };
4611
4611
  } & {
4612
4612
  _: {
4613
- fieldName: "status";
4613
+ fieldName: "direction";
4614
4614
  };
4615
4615
  };
4616
- direction: ConvexTextBuilderInitial<""> & {
4616
+ updatedAt: ConvexNumberBuilderInitial<""> & {
4617
4617
  _: {
4618
4618
  notNull: true;
4619
4619
  };
@@ -4623,10 +4623,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4623
4623
  };
4624
4624
  } & {
4625
4625
  _: {
4626
- fieldName: "direction";
4626
+ fieldName: "updatedAt";
4627
4627
  };
4628
4628
  };
4629
- updatedAt: ConvexNumberBuilderInitial<""> & {
4629
+ status: ConvexTextBuilderInitial<""> & {
4630
4630
  _: {
4631
4631
  notNull: true;
4632
4632
  };
@@ -4636,7 +4636,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4636
4636
  };
4637
4637
  } & {
4638
4638
  _: {
4639
- fieldName: "updatedAt";
4639
+ fieldName: "status";
4640
4640
  };
4641
4641
  };
4642
4642
  startedAt: ConvexNumberBuilderInitial<""> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitcn",
3
- "version": "0.17.1",
3
+ "version": "0.17.3",
4
4
  "description": "kitcn - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",