kitcn 0.33.0 → 0.33.1

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 (38) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/aggregate/index.d.ts +1 -1
  3. package/dist/auth/generated/index.d.ts +1 -1
  4. package/dist/auth/index.d.ts +20 -20
  5. package/dist/auth/nextjs/index.d.ts +2 -2
  6. package/dist/auth/start/server/index.d.ts +2 -2
  7. package/dist/{builder-Cyd5nCxZ.js → builder-DDYTlmTB.js} +12 -3
  8. package/dist/caller-factory-C3pcbzo0.d.ts +140 -0
  9. package/dist/crpc/index.d.ts +3 -2
  10. package/dist/{generated-contract-disabled-PdNGvNYP.d.ts → generated-contract-disabled-B_EaHGCP.d.ts} +42 -42
  11. package/dist/{http-types-BhhPZtwa.d.ts → http-types-8FBr10yl.d.ts} +3 -79
  12. package/dist/{middleware-BBS7oLtT.d.ts → middleware-D2hKJuSZ.d.ts} +1 -1
  13. package/dist/{middleware-D61Nm-iB.js → middleware-LvZov-hA.js} +1 -1
  14. package/dist/orm/index.d.ts +1 -1
  15. package/dist/orm/migrations/index.d.ts +1 -1
  16. package/dist/plugins/index.d.ts +1 -1
  17. package/dist/plugins/index.js +1 -1
  18. package/dist/{procedure-caller-DgMiD0-a.js → procedure-caller-DgGF_hA8.js} +1 -1
  19. package/dist/{procedure-name-DPYyLiVS.d.ts → procedure-name-kn-awLk1.d.ts} +12 -142
  20. package/dist/ratelimit/index.d.ts +2 -2
  21. package/dist/ratelimit/index.js +2 -2
  22. package/dist/react/index.d.ts +5 -6
  23. package/dist/react/index.js +20 -66
  24. package/dist/rsc/index.d.ts +4 -3
  25. package/dist/server/index.d.ts +5 -4
  26. package/dist/server/index.js +2 -2
  27. package/dist/solid/index.d.ts +5 -6
  28. package/dist/solid/index.js +20 -66
  29. package/dist/transformer-BEkxlnss.d.ts +78 -0
  30. package/dist/{types-BXpu7xIU.d.ts → types-Cl0utsTL.d.ts} +4 -3
  31. package/dist/{where-clause-compiler-DrV6lQg0.d.ts → where-clause-compiler-CoPVAVDO.d.ts} +135 -135
  32. package/package.json +1 -1
  33. package/skills/kitcn/SKILL.md +2 -1
  34. package/skills/kitcn/references/features/auth-admin.md +1 -0
  35. package/skills/kitcn/references/features/react.md +4 -5
  36. /package/dist/{context-utils-Cbv4r0AA.d.ts → context-utils-ax351iFc.d.ts} +0 -0
  37. /package/dist/{token-tlbNKQS0.d.ts → token-CZpDQUHd.d.ts} +0 -0
  38. /package/dist/{types-Bkeicpo6.d.ts → types-CzGsrLrY.d.ts} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { a as isMutationCtx, c as isSchedulerCtx, d as requireQueryCtx, f as requireRunMutationCtx, i as isActionCtx, l as requireActionCtx, n as createGeneratedFunctionReference, o as isQueryCtx, p as requireSchedulerCtx, r as getGeneratedValue, s as isRunMutationCtx, t as createApiLeaf, u as requireMutationCtx } from "../api-entry-Buvjl9hn.js";
2
2
  import { n as createLazyCaller, r as createServerCaller, t as createCallerFactory } from "../caller-factory-C-N540BC.js";
3
- import { A as zid, C as toCRPCError, D as zCustomAction, E as withSystemFields, M as zodOutputToConvexFields, N as zodToConvex, O as zCustomMutation, P as zodToConvexFields, S as isCRPCError, T as convexToZodFields, _ as CRPCError, a as createMiddlewareFactory, b as getCRPCErrorFromUnknown, c as registerProcedureNameLookup, d as createHttpRouterFactory, f as extractRouteMap, g as matchPathParams, h as handleHttpError, i as QueryProcedureBuilder, j as zodOutputToConvex, k as zCustomQuery, l as HttpRouterWithHono, m as extractPathParams, n as MutationProcedureBuilder, o as initCRPC, p as createHttpProcedureBuilder, r as ProcedureBuilder, s as inferProcedureNameFromCallsite, t as ActionProcedureBuilder, u as createHttpRouter, v as CRPC_ERROR_CODES_BY_KEY, w as convexToZod, x as getHTTPStatusCodeFromError, y as CRPC_ERROR_CODE_TO_HTTP } from "../builder-Cyd5nCxZ.js";
4
- import { a as createProcedureHandlerFactory, c as typedProcedureResolver, i as createProcedureCallerFactory, l as createEnv, n as createGenericCallerFactory, o as defineProcedure, r as createGenericHandlerFactory, s as getGeneratedFunctionReference, t as createGeneratedRegistryRuntime } from "../procedure-caller-DgMiD0-a.js";
3
+ import { A as zid, C as toCRPCError, D as zCustomAction, E as withSystemFields, M as zodOutputToConvexFields, N as zodToConvex, O as zCustomMutation, P as zodToConvexFields, S as isCRPCError, T as convexToZodFields, _ as CRPCError, a as createMiddlewareFactory, b as getCRPCErrorFromUnknown, c as registerProcedureNameLookup, d as createHttpRouterFactory, f as extractRouteMap, g as matchPathParams, h as handleHttpError, i as QueryProcedureBuilder, j as zodOutputToConvex, k as zCustomQuery, l as HttpRouterWithHono, m as extractPathParams, n as MutationProcedureBuilder, o as initCRPC, p as createHttpProcedureBuilder, r as ProcedureBuilder, s as inferProcedureNameFromCallsite, t as ActionProcedureBuilder, u as createHttpRouter, v as CRPC_ERROR_CODES_BY_KEY, w as convexToZod, x as getHTTPStatusCodeFromError, y as CRPC_ERROR_CODE_TO_HTTP } from "../builder-DDYTlmTB.js";
4
+ import { a as createProcedureHandlerFactory, c as typedProcedureResolver, i as createProcedureCallerFactory, l as createEnv, n as createGenericCallerFactory, o as defineProcedure, r as createGenericHandlerFactory, s as getGeneratedFunctionReference, t as createGeneratedRegistryRuntime } from "../procedure-caller-DgGF_hA8.js";
5
5
 
6
6
  export { ActionProcedureBuilder, CRPCError, CRPC_ERROR_CODES_BY_KEY, CRPC_ERROR_CODE_TO_HTTP, HttpRouterWithHono, MutationProcedureBuilder, ProcedureBuilder, QueryProcedureBuilder, convexToZod, convexToZodFields, createApiLeaf, createCallerFactory, createEnv, createGeneratedFunctionReference, createGeneratedRegistryRuntime, createGenericCallerFactory, createGenericHandlerFactory, createHttpProcedureBuilder, createHttpRouter, createHttpRouterFactory, createLazyCaller, createMiddlewareFactory, createProcedureCallerFactory, createProcedureHandlerFactory, createServerCaller, defineProcedure, extractPathParams, extractRouteMap, getCRPCErrorFromUnknown, getGeneratedFunctionReference, getGeneratedValue, getHTTPStatusCodeFromError, handleHttpError, inferProcedureNameFromCallsite, initCRPC, isActionCtx, isCRPCError, isMutationCtx, isQueryCtx, isRunMutationCtx, isSchedulerCtx, matchPathParams, registerProcedureNameLookup, requireActionCtx, requireMutationCtx, requireQueryCtx, requireRunMutationCtx, requireSchedulerCtx, toCRPCError, typedProcedureResolver, withSystemFields, zCustomAction, zCustomMutation, zCustomQuery, zid, zodOutputToConvex, zodOutputToConvexFields, zodToConvex, zodToConvexFields };
@@ -60,8 +60,8 @@ type ConvexQueryHookOptions = {
60
60
  /** Skip query silently when unauthenticated (default: false, calls onQueryUnauthorized) */skipUnauth?: boolean; /** Set to false to fetch once without subscribing (default: true) */
61
61
  subscribe?: boolean;
62
62
  };
63
- /** Extract input args without cursor/limit (user's filter args only) */
64
- type InfiniteQueryInput<TInput> = Omit<TInput, 'cursor' | 'limit'>;
63
+ /** Extract user args without hook-owned pagination transport fields */
64
+ type InfiniteQueryInput<TInput> = Omit<TInput, 'cursor' | 'endCursor' | 'limit'>;
65
65
  /** Extract item type from PaginationResult<T> */
66
66
  type ExtractPaginatedItem<TOutput> = TOutput extends {
67
67
  page: (infer T)[];
@@ -1429,7 +1429,7 @@ declare const getConvexQueryClientSingleton: ({
1429
1429
  * Pagination state persisted in queryClient.
1430
1430
  * Enables scroll restoration when navigating back to a paginated list.
1431
1431
  *
1432
- * Uses flat { cursor, limit } structure like tRPC.
1432
+ * Uses flat { cursor, endCursor, limit } structure like tRPC.
1433
1433
  */
1434
1434
  type PaginationState = {
1435
1435
  id: number;
@@ -1438,13 +1438,12 @@ type PaginationState = {
1438
1438
  queries: Record<number, {
1439
1439
  /** Flat pagination args - tRPC style */args: Record<string, unknown> & {
1440
1440
  cursor: string | null;
1441
+ endCursor?: string | null;
1441
1442
  limit?: number; /** Internal pagination ID for subscription management */
1442
1443
  __paginationId?: number;
1443
1444
  };
1444
- endCursor?: string | null;
1445
1445
  }>;
1446
- version: number; /** Recovery key to prevent infinite recovery loops */
1447
- autoRecoveryAttempted?: string;
1446
+ version: number;
1448
1447
  };
1449
1448
  type PaginationStatus = 'CanLoadMore' | 'Exhausted' | 'LoadingFirstPage' | 'LoadingMore';
1450
1449
  /** Return type for infinite query hooks */
@@ -2935,6 +2935,12 @@ const getConvexQueryClientSingleton = ({ authStore, convex, queryClient, symbolK
2935
2935
  //#endregion
2936
2936
  //#region src/internal/pagination.ts
2937
2937
  const shouldSplitPaginationPage = (page, initialNumItems) => Boolean(page.splitCursor) && (page.pageStatus === "SplitRecommended" || page.pageStatus === "SplitRequired" || initialNumItems !== void 0 && page.page.length > initialNumItems * 2);
2938
+ const isInvalidPaginationCursor = (error) => {
2939
+ if (error instanceof Error && error.message.includes("InvalidCursor")) return true;
2940
+ if (!error || typeof error !== "object" || !("data" in error)) return false;
2941
+ const data = error.data;
2942
+ return Boolean(data && typeof data === "object" && "isConvexSystemError" in data && data.isConvexSystemError === true && "paginationError" in data && data.paginationError === "InvalidCursor");
2943
+ };
2938
2944
 
2939
2945
  //#endregion
2940
2946
  //#region src/solid/create-queries-results.ts
@@ -3020,7 +3026,7 @@ const aggregatePages = (results, hasPlaceholderData) => {
3020
3026
  error,
3021
3027
  failureReason: error,
3022
3028
  isError: results.some((r) => r.isError),
3023
- isFetchNextPageError: results.length > 1 && (results.at(-1)?.isError ?? false),
3029
+ isFetchNextPageError: results.slice(1).some((result) => result.isError),
3024
3030
  isFetching,
3025
3031
  isLoading: status === "LoadingFirstPage",
3026
3032
  isPlaceholderData,
@@ -3030,72 +3036,18 @@ const aggregatePages = (results, hasPlaceholderData) => {
3030
3036
  status
3031
3037
  };
3032
3038
  };
3033
- /** Build a unique key for recovery attempt detection */
3034
- const buildRecoveryKey = (pageKeys, page0Cursor, page0UpdatedAt) => JSON.stringify({
3035
- pageKeys,
3036
- page0Cursor,
3037
- page0UpdatedAt
3038
- });
3039
3039
  /**
3040
3040
  * Hook for auto-recovering from stale cursors after WebSocket reconnection.
3041
3041
  *
3042
3042
  * When Convex WebSocket reconnects, page 0 (cursor: null) resubscribes and
3043
3043
  * gets fresh data. However, pages 1+ may have stale cursors that fail.
3044
3044
  *
3045
- * This hook detects this pattern and creates a recovery page that fetches
3046
- * enough items to cover the lost pages, preserving the user's scroll position.
3045
+ * This hook discards the invalid cursor chain and restarts from page one.
3047
3046
  */
3048
- const useStaleCursorRecovery = ({ argsObject, combined, limit, pageResults, setState, state }) => {
3049
- createEffect(on([
3050
- () => combined.isFetchNextPageError,
3051
- pageResults,
3052
- () => state().pageKeys,
3053
- () => state().queries,
3054
- () => state().autoRecoveryAttempted,
3055
- argsObject
3056
- ], () => {
3047
+ const useStaleCursorRecovery = ({ combined, pageResults, resetPagination }) => {
3048
+ createEffect(on([() => combined.isFetchNextPageError, pageResults], () => {
3057
3049
  if (!combined.isFetchNextPageError) return;
3058
- const results = pageResults();
3059
- const page0Result = results[0];
3060
- const page0Data = page0Result?.data;
3061
- const page0UpdatedAt = page0Result?.dataUpdatedAt ?? 0;
3062
- const hasPage0Data = page0Data !== void 0 && !page0Result?.isError;
3063
- const hasSubsequentErrors = results.slice(1).some((q) => q?.isError && !q?.isFetching);
3064
- if (!hasPage0Data || !hasSubsequentErrors || !page0Data?.continueCursor) return;
3065
- const currentState = state();
3066
- const recoveryKey = buildRecoveryKey(currentState.pageKeys, page0Data.continueCursor, page0UpdatedAt);
3067
- if (currentState.autoRecoveryAttempted === recoveryKey) return;
3068
- const erroredPageKeys = currentState.pageKeys.filter((_, i) => i > 0 && results[i]?.isError);
3069
- const itemsToRecover = erroredPageKeys.reduce((sum, key) => {
3070
- return sum + (currentState.queries[key]?.args?.limit ?? limit ?? 20);
3071
- }, 0);
3072
- console.warn("[Pagination] Auto-recovering from stale cursors", {
3073
- erroredPages: erroredPageKeys.length,
3074
- itemsToRecover
3075
- });
3076
- setState((prev) => ({
3077
- ...prev,
3078
- id: prev.id,
3079
- nextPageKey: 2,
3080
- pageKeys: [prev.pageKeys[0], 1],
3081
- queries: {
3082
- [prev.pageKeys[0]]: prev.queries[prev.pageKeys[0]],
3083
- 1: { args: {
3084
- ...argsObject(),
3085
- cursor: page0Data.continueCursor,
3086
- limit: Math.min(itemsToRecover + (limit ?? 20), 500),
3087
- __paginationId: prev.id
3088
- } }
3089
- },
3090
- version: prev.version + 1,
3091
- autoRecoveryAttempted: recoveryKey
3092
- }));
3093
- }));
3094
- createEffect(on([() => combined.status, () => state().autoRecoveryAttempted], () => {
3095
- if ((combined.status === "CanLoadMore" || combined.status === "Exhausted") && state().autoRecoveryAttempted) setState((prev) => ({
3096
- ...prev,
3097
- autoRecoveryAttempted: void 0
3098
- }));
3050
+ if (pageResults().slice(1).some((result) => result?.isError && !result.isFetching && isInvalidPaginationCursor(result.error))) resetPagination();
3099
3051
  }));
3100
3052
  };
3101
3053
  /**
@@ -3232,12 +3184,9 @@ const useInfiniteQueryInternal = (query, args, options) => {
3232
3184
  const [combined, setCombined] = createStore(derive());
3233
3185
  createRenderEffect(() => setCombined(derive()));
3234
3186
  useStaleCursorRecovery({
3235
- argsObject,
3236
3187
  combined,
3237
- limit,
3238
3188
  pageResults,
3239
- setState,
3240
- state
3189
+ resetPagination: () => setState(createInitialState())
3241
3190
  });
3242
3191
  createEffect(on([
3243
3192
  pageResults,
@@ -3252,15 +3201,17 @@ const useInfiniteQueryInternal = (query, args, options) => {
3252
3201
  const page = pageQuery.data;
3253
3202
  const pageKey = state().pageKeys[i];
3254
3203
  const pageState = state().queries[pageKey];
3255
- if (shouldSplitPaginationPage(page, limit) && pageState && !pageState.endCursor) {
3204
+ if (shouldSplitPaginationPage(page, limit) && pageState && pageState.args.endCursor !== page.splitCursor) {
3256
3205
  setState((prev) => {
3257
3206
  const currentPageState = prev.queries[pageKey];
3258
- if (!currentPageState || currentPageState.endCursor) return prev;
3207
+ if (!currentPageState || currentPageState.args.endCursor === page.splitCursor) return prev;
3259
3208
  const newKey = prev.nextPageKey;
3260
3209
  const splitCursor = page.splitCursor;
3210
+ const endCursor = currentPageState.args.endCursor ?? page.continueCursor;
3261
3211
  const splitPageArgs = {
3262
3212
  ...argsObject(),
3263
3213
  cursor: splitCursor,
3214
+ endCursor,
3264
3215
  limit: currentPageState.args.limit,
3265
3216
  __paginationId: prev.id
3266
3217
  };
@@ -3275,7 +3226,10 @@ const useInfiniteQueryInternal = (query, args, options) => {
3275
3226
  ...prev.queries,
3276
3227
  [pageKey]: {
3277
3228
  ...currentPageState,
3278
- endCursor: splitCursor
3229
+ args: {
3230
+ ...currentPageState.args,
3231
+ endCursor: splitCursor
3232
+ }
3279
3233
  },
3280
3234
  [newKey]: { args: splitPageArgs }
3281
3235
  }
@@ -0,0 +1,78 @@
1
+ //#region src/crpc/transformer.d.ts
2
+ /**
3
+ * Generic transformer contract (mirrors tRPC shape).
4
+ */
5
+ interface DataTransformer {
6
+ deserialize(object: any): any;
7
+ serialize(object: any): any;
8
+ }
9
+ /**
10
+ * Separate input/output transformers.
11
+ */
12
+ interface CombinedDataTransformer {
13
+ input: DataTransformer;
14
+ output: DataTransformer;
15
+ }
16
+ /**
17
+ * Transformer config accepted by cRPC.
18
+ */
19
+ type DataTransformerOptions = CombinedDataTransformer | DataTransformer;
20
+ /**
21
+ * Extensible tagged wire codec.
22
+ */
23
+ interface WireCodec {
24
+ decode(value: unknown): unknown;
25
+ encode(value: unknown): unknown;
26
+ isType(value: unknown): boolean;
27
+ /**
28
+ * Declares that `isType` only ever claims a value where
29
+ * `typeof value === 'object' && value !== null` - never a primitive, a
30
+ * function, `null` or `undefined`.
31
+ *
32
+ * Lets `serialize` skip codec dispatch on primitives, which are the majority
33
+ * of visited nodes. It is opt-in because an arbitrary predicate cannot be
34
+ * classified by sampling values: a codec that claims, say, one specific
35
+ * number would be misread as object-only and silently lose its encoding.
36
+ * Codecs that leave it unset keep full dispatch.
37
+ */
38
+ readonly objectsOnly?: boolean;
39
+ readonly tag: `$${string}`;
40
+ }
41
+ /**
42
+ * Date wire tag (Convex-style reserved key).
43
+ */
44
+ declare const DATE_CODEC_TAG = "$date";
45
+ /**
46
+ * Built-in Date codec.
47
+ */
48
+ declare const dateWireCodec: WireCodec;
49
+ /**
50
+ * Build a recursive tagged transformer from codecs.
51
+ */
52
+ declare const createTaggedTransformer: (codecs: readonly WireCodec[]) => DataTransformer;
53
+ /**
54
+ * Default cRPC transformer (Date-enabled).
55
+ */
56
+ declare const defaultCRPCTransformer: DataTransformer;
57
+ /**
58
+ * Normalize transformer config to split input/output shape.
59
+ * User transformers are additive and always composed with default Date handling.
60
+ *
61
+ * Idempotent: passing a transformer this function already resolved returns it
62
+ * unchanged.
63
+ */
64
+ declare const getTransformer: (transformer?: DataTransformerOptions) => CombinedDataTransformer;
65
+ /**
66
+ * Encode request payloads (input direction).
67
+ */
68
+ declare const encodeWire: (value: unknown, transformer?: DataTransformerOptions) => unknown;
69
+ /**
70
+ * Decode response payloads (output direction).
71
+ */
72
+ declare const decodeWire: (value: unknown, transformer?: DataTransformerOptions) => unknown;
73
+ /**
74
+ * Exposed identity transformer for advanced composition.
75
+ */
76
+ declare const identityTransformer: CombinedDataTransformer;
77
+ //#endregion
78
+ export { WireCodec as a, decodeWire as c, getTransformer as d, identityTransformer as f, DataTransformerOptions as i, defaultCRPCTransformer as l, DATE_CODEC_TAG as n, createTaggedTransformer as o, DataTransformer as r, dateWireCodec as s, CombinedDataTransformer as t, encodeWire as u };
@@ -1,4 +1,5 @@
1
- import { P as CombinedDataTransformer, r as HttpClientError } from "./http-types-BhhPZtwa.js";
1
+ import { t as CombinedDataTransformer } from "./transformer-BEkxlnss.js";
2
+ import { r as HttpClientError } from "./http-types-8FBr10yl.js";
2
3
  import { FunctionArgs, FunctionReference, FunctionReturnType } from "convex/server";
3
4
 
4
5
  //#region src/crpc/http-client.d.ts
@@ -148,8 +149,8 @@ type PaginationOpts = {
148
149
  maximumRowsRead?: number;
149
150
  maximumBytesRead?: number;
150
151
  };
151
- /** Extract input args without cursor/limit (user's filter args only) */
152
- type InfiniteQueryInput<TInput> = Omit<TInput, 'cursor' | 'limit'>;
152
+ /** Extract user args without hook-owned pagination transport fields */
153
+ type InfiniteQueryInput<TInput> = Omit<TInput, 'cursor' | 'endCursor' | 'limit'>;
153
154
  /** Extract item type from PaginationResult<T> */
154
155
  type ExtractPaginatedItem<TOutput> = TOutput extends {
155
156
  page: (infer T)[];