kitcn 0.15.1 → 0.15.4

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.
@@ -1107,6 +1107,7 @@ type RuntimeEnv = Record<string, string | undefined>;
1107
1107
  type CreateEnvOptions<TSchema extends z.ZodObject<z.ZodRawShape>> = {
1108
1108
  cache?: boolean;
1109
1109
  codegenFallback?: boolean;
1110
+ readOptionalRuntimeEnv?: readonly string[];
1110
1111
  runtimeEnv?: RuntimeEnv;
1111
1112
  schema: TSchema;
1112
1113
  };
@@ -1366,4 +1367,4 @@ type ProcedureNameLookup = Record<string, ProcedureNameEntry[]>;
1366
1367
  declare function registerProcedureNameLookup(lookup: ProcedureNameLookup, functionsDirHint: string): void;
1367
1368
  declare function inferProcedureNameFromCallsite(): string | undefined;
1368
1369
  //#endregion
1369
- export { CRPCFunctionTypeHint as $, CRPCError as A, createEnv as B, createProcedureHandlerFactory as C, zid as Ct, WithHttpRouter as D, zodToConvexFields as Dt, typedProcedureResolver as E, zodToConvex as Et, getCRPCErrorFromUnknown as F, CallerMeta as G, createCallerFactory as H, getHTTPStatusCodeFromError as I, createServerCaller as J, CallerOpts as K, isCRPCError as L, CRPCErrorData as M, CRPC_ERROR_CODES_BY_KEY as N, inferApiInputs as O, CRPC_ERROR_CODE_TO_HTTP as P, ActionProcedureBuilder as Q, toCRPCError as R, createProcedureCallerFactory as S, zCustomQuery as St, getGeneratedFunctionReference as T, zodOutputToConvexFields as Tt, LazyCaller as U, ConvexContext as V, createLazyCaller as W, createGeneratedFunctionReference as X, createApiLeaf as Y, getGeneratedValue as Z, ProcedureSchedulableCallerFromRegistry as _, convexToZod as _t, CreateProcedureCallerFactoryOptions as a, HttpProcedureBuilder as at, createGenericCallerFactory as b, zCustomAction as bt, GeneratedRegistryCallerFactory as c, handleHttpError as ct, GeneratedRegistryHandlerForContext as d, ConvexValidatorFromZodOutput as dt, MutationProcedureBuilder as et, ProcedureActionCallerFromRegistry as f, CustomBuilder as ft, ProcedureFromFunctionReference as g, ZodValidatorFromConvex as gt, ProcedureDefinition as h, ZodFromValidatorBase as ht, registerProcedureNameLookup as i, initCRPC as it, CRPCErrorCode as j, inferApiOutputs as k, GeneratedRegistryCallerForContext as l, matchPathParams as lt, ProcedureCallerFromRegistry as m, Zid as mt, ProcedureNameLookup as n, QueryProcedureBuilder as nt, GeneratedProcedureRegistry as o, createHttpProcedureBuilder as ot, ProcedureCaller as p, ZCustomCtx as pt, ServerCaller as q, inferProcedureNameFromCallsite as r, createMiddlewareFactory as rt, GeneratedProcedureRegistryEntry as s, extractPathParams as st, ProcedureNameEntry as t, ProcedureBuilder as tt, GeneratedRegistryHandlerFactory as u, ConvexValidatorFromZod as ut, ProcedureScheduleCallerFromRegistry as v, convexToZodFields as vt, defineProcedure as w, zodOutputToConvex as wt, createGenericHandlerFactory as x, zCustomMutation as xt, createGeneratedRegistryRuntime as y, withSystemFields as yt, CreateEnvOptions as z };
1370
+ export { ActionProcedureBuilder as $, CRPCError as A, RuntimeEnv as B, createProcedureHandlerFactory as C, zCustomQuery as Ct, WithHttpRouter as D, zodToConvex as Dt, typedProcedureResolver as E, zodOutputToConvexFields as Et, getCRPCErrorFromUnknown as F, createLazyCaller as G, ConvexContext as H, getHTTPStatusCodeFromError as I, ServerCaller as J, CallerMeta as K, isCRPCError as L, CRPCErrorData as M, CRPC_ERROR_CODES_BY_KEY as N, inferApiInputs as O, zodToConvexFields as Ot, CRPC_ERROR_CODE_TO_HTTP as P, getGeneratedValue as Q, toCRPCError as R, createProcedureCallerFactory as S, zCustomMutation as St, getGeneratedFunctionReference as T, zodOutputToConvex as Tt, createCallerFactory as U, createEnv as V, LazyCaller as W, createApiLeaf as X, createServerCaller as Y, createGeneratedFunctionReference as Z, ProcedureSchedulableCallerFromRegistry as _, ZodValidatorFromConvex as _t, CreateProcedureCallerFactoryOptions as a, initCRPC as at, createGenericCallerFactory as b, withSystemFields as bt, GeneratedRegistryCallerFactory as c, extractPathParams as ct, GeneratedRegistryHandlerForContext as d, ConvexValidatorFromZod as dt, CRPCFunctionTypeHint as et, ProcedureActionCallerFromRegistry as f, ConvexValidatorFromZodOutput as ft, ProcedureFromFunctionReference as g, ZodFromValidatorBase as gt, ProcedureDefinition as h, Zid as ht, registerProcedureNameLookup as i, createMiddlewareFactory as it, CRPCErrorCode as j, inferApiOutputs as k, GeneratedRegistryCallerForContext as l, handleHttpError as lt, ProcedureCallerFromRegistry as m, ZCustomCtx as mt, ProcedureNameLookup as n, ProcedureBuilder as nt, GeneratedProcedureRegistry as o, HttpProcedureBuilder as ot, ProcedureCaller as p, CustomBuilder as pt, CallerOpts as q, inferProcedureNameFromCallsite as r, QueryProcedureBuilder as rt, GeneratedProcedureRegistryEntry as s, createHttpProcedureBuilder as st, ProcedureNameEntry as t, MutationProcedureBuilder as tt, GeneratedRegistryHandlerFactory as u, matchPathParams as ut, ProcedureScheduleCallerFromRegistry as v, convexToZod as vt, defineProcedure as w, zid as wt, createGenericHandlerFactory as x, zCustomAction as xt, createGeneratedRegistryRuntime as y, convexToZodFields as yt, CreateEnvOptions as z };
@@ -1,13 +1,11 @@
1
1
  'use client';
2
- import { ConvexProvider, ConvexProviderWithAuth as ConvexProviderWithAuth$1, ConvexReactClient, ConvexReactClient as ConvexReactClient$1, ConvexReactClientOptions, Watch, WatchQueryOptions, useConvex } from "convex/react";
3
- import * as react from "react";
2
+ import { C as useMaybeAuth, S as useIsAuth, _ as useAuthState, a as Authenticated, b as useConvexAuthBridge, c as FetchAccessTokenContext, d as MaybeUnauthenticated, f as Unauthenticated, g as useAuthGuard, h as useAuth, i as AuthStoreState, l as FetchAccessTokenFn, m as isSessionSyncGraceActive, n as AuthProvider, o as ConvexAuthBridge, p as decodeJwtExp, r as AuthStore, s as ConvexProviderWithAuth, t as AUTH_SESSION_SYNC_GRACE_MS, u as MaybeAuthenticated, v as useAuthStore, w as useSafeConvexAuth, x as useFetchAccessToken, y as useAuthValue } from "../auth-store-B_ARzzEX.js";
3
+ import { ConvexProvider, ConvexReactClient, ConvexReactClient as ConvexReactClient$1, ConvexReactClientOptions, Watch, WatchQueryOptions, useConvex } from "convex/react";
4
4
  import { ReactNode } from "react";
5
- import * as jotai_x0 from "jotai-x";
6
5
  import * as react_jsx_runtime0 from "react/jsx-runtime";
7
6
  import { FunctionArgs, FunctionReference, FunctionReturnType } from "convex/server";
8
7
  import { DefaultError, QueryCache, QueryClient, QueryFilters, QueryFunction, QueryFunctionContext, QueryKey, SkipToken, UseMutationOptions, UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
9
8
  import { ConvexHttpClient } from "convex/browser";
10
- import * as jotai_vanilla0 from "jotai/vanilla";
11
9
  import { z } from "zod";
12
10
 
13
11
  //#region src/crpc/auth-error.d.ts
@@ -112,154 +110,6 @@ type AuthMutationsResult = {
112
110
  };
113
111
  declare function createAuthMutations(authClient: AuthClient): AuthMutationsResult;
114
112
  //#endregion
115
- //#region src/react/auth-store.d.ts
116
- type FetchAccessTokenFn = (args: {
117
- forceRefreshToken: boolean;
118
- }) => Promise<string | null>;
119
- declare const FetchAccessTokenContext: react.Context<FetchAccessTokenFn | null>;
120
- /** Get fetchAccessToken from context (available immediately, no race condition) */
121
- declare const useFetchAccessToken: () => FetchAccessTokenFn | null;
122
- type ConvexAuthResult = {
123
- isAuthenticated: boolean;
124
- isLoading: boolean;
125
- };
126
- /** Get auth from bridge context (null if no bridge configured) */
127
- declare const useConvexAuthBridge: () => ConvexAuthResult | null;
128
- type AuthStoreState = {
129
- /** Callback when mutation/action called while unauthorized. Throws by default. */onMutationUnauthorized: () => void; /** Callback when query called while unauthorized. Noop by default. */
130
- onQueryUnauthorized: (info: {
131
- queryName: string;
132
- }) => void; /** Custom function to detect UNAUTHORIZED errors. Default checks code or "auth" in message. */
133
- isUnauthorized: (error: unknown) => boolean; /** Cached Convex JWT for HTTP requests */
134
- token: string | null; /** JWT expiration timestamp (ms) */
135
- expiresAt: number | null; /** Auth loading state (synced from useConvexAuth for class methods) */
136
- isLoading: boolean; /** Auth state (synced from useConvexAuth for class methods) */
137
- isAuthenticated: boolean; /** Grace window for freshly seeded auth tokens while session sync catches up */
138
- sessionSyncGraceUntil: number | null;
139
- };
140
- declare const AUTH_SESSION_SYNC_GRACE_MS = 10000;
141
- declare const isSessionSyncGraceActive: (sessionSyncGraceUntil: number | null) => boolean;
142
- /** Decode JWT expiration (ms timestamp) from token */
143
- declare function decodeJwtExp(token: string): number | null;
144
- declare const AuthProvider: react.FC<jotai_x0.ProviderProps<{
145
- onMutationUnauthorized: () => void;
146
- onQueryUnauthorized: (info: {
147
- queryName: string;
148
- }) => void;
149
- isUnauthorized: (error: unknown) => boolean;
150
- token: string | null;
151
- expiresAt: number | null;
152
- isLoading: boolean;
153
- isAuthenticated: boolean;
154
- sessionSyncGraceUntil: number | null;
155
- }>>, useAuthStore: jotai_x0.UseStoreApi<AuthStoreState, object>, useAuthState: <K extends keyof AuthStoreState>(key: K, options?: string | jotai_x0.UseAtomOptions) => ({
156
- onMutationUnauthorized: jotai_x0.SimpleWritableAtom<() => void>;
157
- onQueryUnauthorized: jotai_x0.SimpleWritableAtom<(info: {
158
- queryName: string;
159
- }) => void>;
160
- isUnauthorized: jotai_x0.SimpleWritableAtom<(error: unknown) => boolean>;
161
- token: jotai_x0.SimpleWritableAtom<string | null>;
162
- expiresAt: jotai_x0.SimpleWritableAtom<number | null>;
163
- isLoading: jotai_x0.SimpleWritableAtom<boolean>;
164
- isAuthenticated: jotai_x0.SimpleWritableAtom<boolean>;
165
- sessionSyncGraceUntil: jotai_x0.SimpleWritableAtom<number | null>;
166
- } & object)[K] extends jotai_vanilla0.WritableAtom<infer V, infer A extends unknown[], infer R> ? [V, (...args: A) => R] : never, useAuthValue: <K extends keyof AuthStoreState, S = (({
167
- onMutationUnauthorized: jotai_x0.SimpleWritableAtom<() => void>;
168
- onQueryUnauthorized: jotai_x0.SimpleWritableAtom<(info: {
169
- queryName: string;
170
- }) => void>;
171
- isUnauthorized: jotai_x0.SimpleWritableAtom<(error: unknown) => boolean>;
172
- token: jotai_x0.SimpleWritableAtom<string | null>;
173
- expiresAt: jotai_x0.SimpleWritableAtom<number | null>;
174
- isLoading: jotai_x0.SimpleWritableAtom<boolean>;
175
- isAuthenticated: jotai_x0.SimpleWritableAtom<boolean>;
176
- sessionSyncGraceUntil: jotai_x0.SimpleWritableAtom<number | null>;
177
- } & object)[K] extends jotai_vanilla0.Atom<infer V> ? V : never)>(key: K, options?: ({
178
- selector?: ((v: ({
179
- onMutationUnauthorized: jotai_x0.SimpleWritableAtom<() => void>;
180
- onQueryUnauthorized: jotai_x0.SimpleWritableAtom<(info: {
181
- queryName: string;
182
- }) => void>;
183
- isUnauthorized: jotai_x0.SimpleWritableAtom<(error: unknown) => boolean>;
184
- token: jotai_x0.SimpleWritableAtom<string | null>;
185
- expiresAt: jotai_x0.SimpleWritableAtom<number | null>;
186
- isLoading: jotai_x0.SimpleWritableAtom<boolean>;
187
- isAuthenticated: jotai_x0.SimpleWritableAtom<boolean>;
188
- sessionSyncGraceUntil: jotai_x0.SimpleWritableAtom<number | null>;
189
- } & object)[K] extends jotai_vanilla0.Atom<infer V_1> ? V_1 : never, prevSelectorOutput?: S | undefined) => S) | undefined;
190
- equalityFn?: ((prev: S, next: S) => boolean) | undefined;
191
- } & jotai_x0.UseAtomOptions) | undefined, deps?: unknown[]) => S;
192
- type AuthStore = ReturnType<typeof useAuthStore>;
193
- /**
194
- * Safe wrapper around useConvexAuth that doesn't throw when used outside auth provider.
195
- * Returns { isAuthenticated: false, isLoading: false } when no auth provider.
196
- *
197
- * Supports both:
198
- * - better-auth users (via AuthProvider)
199
- * - @convex-dev/auth users (via ConvexAuthBridge)
200
- */
201
- declare function useSafeConvexAuth(): ConvexAuthResult;
202
- /**
203
- * Internal bridge component. Use `ConvexProviderWithAuth` instead.
204
- * @internal
205
- */
206
- declare function ConvexAuthBridge({
207
- children
208
- }: {
209
- children: React.ReactNode;
210
- }): react_jsx_runtime0.JSX.Element;
211
- /**
212
- * Convex provider with auth bridge for @convex-dev/auth users.
213
- * Automatically wraps children with ConvexAuthBridge.
214
- *
215
- * @example
216
- * ```tsx
217
- * import { ConvexProviderWithAuth } from 'kitcn/react';
218
- *
219
- * <ConvexProviderWithAuth client={convex} useAuth={useAuthFromConvexDev}>
220
- * <App />
221
- * </ConvexProviderWithAuth>
222
- * ```
223
- */
224
- declare function ConvexProviderWithAuth({
225
- children,
226
- ...props
227
- }: React.ComponentProps<typeof ConvexProviderWithAuth$1>): react_jsx_runtime0.JSX.Element;
228
- declare const useAuth: () => {
229
- hasSession: boolean;
230
- isAuthenticated: boolean;
231
- isLoading: boolean;
232
- };
233
- /** Check if user maybe has auth (optimistic, has token) */
234
- declare const useMaybeAuth: () => boolean;
235
- /** Check if user is authenticated (server-verified) */
236
- declare const useIsAuth: () => boolean;
237
- declare const useAuthGuard: () => (callback?: () => Promise<void> | void) => boolean | undefined;
238
- /** Render children only when maybe has auth (optimistic) */
239
- declare function MaybeAuthenticated({
240
- children
241
- }: {
242
- children: React.ReactNode;
243
- }): react.ReactNode;
244
- /** Render children only when authenticated (server-verified) */
245
- declare function Authenticated({
246
- children
247
- }: {
248
- children: React.ReactNode;
249
- }): react.ReactNode;
250
- /** Render children only when maybe not auth (optimistic) */
251
- declare function MaybeUnauthenticated({
252
- children
253
- }: {
254
- children: React.ReactNode;
255
- }): react.ReactNode;
256
- /** Render children only when not authenticated (server-verified) */
257
- declare function Unauthenticated({
258
- children
259
- }: {
260
- children: React.ReactNode;
261
- }): react.ReactNode;
262
- //#endregion
263
113
  //#region src/crpc/transformer.d.ts
264
114
  /**
265
115
  * Generic transformer contract (mirrors tRPC shape).
@@ -1926,7 +1926,7 @@ var ConvexQueryClient = class {
1926
1926
  }
1927
1927
  if (result.ok) {
1928
1928
  const existingData = this.queryClient.getQueryData(queryKey);
1929
- if (result.value !== null && result.value !== void 0 || !(existingData !== null && existingData !== void 0)) this.queryClient.setQueryData(queryKey, this.transformer.output.deserialize(result.value));
1929
+ if (result.value !== void 0 || !(existingData !== void 0)) this.queryClient.setQueryData(queryKey, this.transformer.output.deserialize(result.value));
1930
1930
  } else {
1931
1931
  const { error } = result;
1932
1932
  const authState = this.getAuthState();
@@ -1,5 +1,5 @@
1
- import { $ as CRPCFunctionTypeHint, A as CRPCError, B as createEnv, C as createProcedureHandlerFactory, Ct as zid, D as WithHttpRouter, Dt as zodToConvexFields, E as typedProcedureResolver, Et as zodToConvex, F as getCRPCErrorFromUnknown, G as CallerMeta, H as createCallerFactory, I as getHTTPStatusCodeFromError, J as createServerCaller, K as CallerOpts, L as isCRPCError, M as CRPCErrorData, N as CRPC_ERROR_CODES_BY_KEY, O as inferApiInputs, P as CRPC_ERROR_CODE_TO_HTTP, Q as ActionProcedureBuilder, R as toCRPCError, S as createProcedureCallerFactory, St as zCustomQuery, T as getGeneratedFunctionReference, Tt as zodOutputToConvexFields, U as LazyCaller, V as ConvexContext, W as createLazyCaller, X as createGeneratedFunctionReference, Y as createApiLeaf, Z as getGeneratedValue, _ as ProcedureSchedulableCallerFromRegistry, _t as convexToZod, a as CreateProcedureCallerFactoryOptions, at as HttpProcedureBuilder, b as createGenericCallerFactory, bt as zCustomAction, c as GeneratedRegistryCallerFactory, ct as handleHttpError, d as GeneratedRegistryHandlerForContext, dt as ConvexValidatorFromZodOutput, et as MutationProcedureBuilder, f as ProcedureActionCallerFromRegistry, ft as CustomBuilder, g as ProcedureFromFunctionReference, gt as ZodValidatorFromConvex, h as ProcedureDefinition, ht as ZodFromValidatorBase, i as registerProcedureNameLookup, it as initCRPC, j as CRPCErrorCode, k as inferApiOutputs, l as GeneratedRegistryCallerForContext, lt as matchPathParams, m as ProcedureCallerFromRegistry, mt as Zid, n as ProcedureNameLookup, nt as QueryProcedureBuilder, o as GeneratedProcedureRegistry, ot as createHttpProcedureBuilder, p as ProcedureCaller, pt as ZCustomCtx, q as ServerCaller, r as inferProcedureNameFromCallsite, rt as createMiddlewareFactory, s as GeneratedProcedureRegistryEntry, st as extractPathParams, t as ProcedureNameEntry, tt as ProcedureBuilder, u as GeneratedRegistryHandlerFactory, ut as ConvexValidatorFromZod, v as ProcedureScheduleCallerFromRegistry, vt as convexToZodFields, w as defineProcedure, wt as zodOutputToConvex, x as createGenericHandlerFactory, xt as zCustomMutation, y as createGeneratedRegistryRuntime, yt as withSystemFields, z as CreateEnvOptions } from "../procedure-name-BCRBr6Po.js";
1
+ import { $ as ActionProcedureBuilder, A as CRPCError, B as RuntimeEnv, C as createProcedureHandlerFactory, Ct as zCustomQuery, D as WithHttpRouter, Dt as zodToConvex, E as typedProcedureResolver, Et as zodOutputToConvexFields, F as getCRPCErrorFromUnknown, G as createLazyCaller, H as ConvexContext, I as getHTTPStatusCodeFromError, J as ServerCaller, K as CallerMeta, L as isCRPCError, M as CRPCErrorData, N as CRPC_ERROR_CODES_BY_KEY, O as inferApiInputs, Ot as zodToConvexFields, P as CRPC_ERROR_CODE_TO_HTTP, Q as getGeneratedValue, R as toCRPCError, S as createProcedureCallerFactory, St as zCustomMutation, T as getGeneratedFunctionReference, Tt as zodOutputToConvex, U as createCallerFactory, V as createEnv, W as LazyCaller, X as createApiLeaf, Y as createServerCaller, Z as createGeneratedFunctionReference, _ as ProcedureSchedulableCallerFromRegistry, _t as ZodValidatorFromConvex, a as CreateProcedureCallerFactoryOptions, at as initCRPC, b as createGenericCallerFactory, bt as withSystemFields, c as GeneratedRegistryCallerFactory, ct as extractPathParams, d as GeneratedRegistryHandlerForContext, dt as ConvexValidatorFromZod, et as CRPCFunctionTypeHint, f as ProcedureActionCallerFromRegistry, ft as ConvexValidatorFromZodOutput, g as ProcedureFromFunctionReference, gt as ZodFromValidatorBase, h as ProcedureDefinition, ht as Zid, i as registerProcedureNameLookup, it as createMiddlewareFactory, j as CRPCErrorCode, k as inferApiOutputs, l as GeneratedRegistryCallerForContext, lt as handleHttpError, m as ProcedureCallerFromRegistry, mt as ZCustomCtx, n as ProcedureNameLookup, nt as ProcedureBuilder, o as GeneratedProcedureRegistry, ot as HttpProcedureBuilder, p as ProcedureCaller, pt as CustomBuilder, q as CallerOpts, r as inferProcedureNameFromCallsite, rt as QueryProcedureBuilder, s as GeneratedProcedureRegistryEntry, st as createHttpProcedureBuilder, t as ProcedureNameEntry, tt as MutationProcedureBuilder, u as GeneratedRegistryHandlerFactory, ut as matchPathParams, v as ProcedureScheduleCallerFromRegistry, vt as convexToZod, w as defineProcedure, wt as zid, x as createGenericHandlerFactory, xt as zCustomAction, y as createGeneratedRegistryRuntime, yt as convexToZodFields, z as CreateEnvOptions } from "../procedure-name-Cy1AxayA.js";
2
2
  import { C as HttpProcedure, D as ProcedureMeta, E as InferHttpInput, S as HttpMethod, T as HttpRouteDefinition, _ as extractRouteMap, b as HttpActionHandler, d as CRPCHttpRouter, f as HttpRouterDef, g as createHttpRouterFactory, h as createHttpRouter, m as HttpRouterWithHono, p as HttpRouterRecord, v as CRPCHonoHandler, w as HttpProcedureBuilderDef, x as HttpHandlerOpts, y as HttpActionConstructor } from "../http-types-zsMHb_QN.js";
3
3
  import { a as MergeZodObjects, c as MiddlewareMarker, d as MiddlewareProcedureType, f as MiddlewareResult, g as UnsetMarker, h as Simplify, i as IntersectIfDefined, l as MiddlewareNext, m as ResolveIfSet, n as AnyMiddlewareBuilder, o as MiddlewareBuilder, p as Overwrite, r as GetRawInputFn, s as MiddlewareFunction, t as AnyMiddleware, u as MiddlewareProcedureInfo } from "../types-CnTpHR1F.js";
4
4
  import { a as isMutationCtx, c as isSchedulerCtx, d as requireQueryCtx, f as requireRunMutationCtx, i as isActionCtx, l as requireActionCtx, n as RunMutationCtx, o as isQueryCtx, p as requireSchedulerCtx, r as SchedulerCtx, s as isRunMutationCtx, t as GenericCtx, u as requireMutationCtx } from "../context-utils-OMkMGhBk.js";
5
- export { ActionProcedureBuilder, AnyMiddleware, AnyMiddlewareBuilder, CRPCError, CRPCErrorCode, CRPCErrorData, CRPCFunctionTypeHint, CRPCHonoHandler, CRPCHttpRouter, CRPC_ERROR_CODES_BY_KEY, CRPC_ERROR_CODE_TO_HTTP, CallerMeta, CallerOpts, ConvexContext, ConvexValidatorFromZod, ConvexValidatorFromZodOutput, CreateEnvOptions, CreateProcedureCallerFactoryOptions, CustomBuilder, GeneratedProcedureRegistry, GeneratedProcedureRegistryEntry, GeneratedRegistryCallerFactory, GeneratedRegistryCallerForContext, GeneratedRegistryHandlerFactory, GeneratedRegistryHandlerForContext, GenericCtx, GetRawInputFn, HttpActionConstructor, HttpActionHandler, HttpHandlerOpts, HttpMethod, HttpProcedure, HttpProcedureBuilder, HttpProcedureBuilderDef, HttpRouteDefinition, HttpRouterDef, HttpRouterRecord, HttpRouterWithHono, InferHttpInput, IntersectIfDefined, LazyCaller, MergeZodObjects, MiddlewareBuilder, MiddlewareFunction, MiddlewareMarker, MiddlewareNext, MiddlewareProcedureInfo, MiddlewareProcedureType, MiddlewareResult, MutationProcedureBuilder, Overwrite, ProcedureActionCallerFromRegistry, ProcedureBuilder, ProcedureCaller, ProcedureCallerFromRegistry, ProcedureDefinition, ProcedureFromFunctionReference, ProcedureMeta, ProcedureNameEntry, ProcedureNameLookup, ProcedureSchedulableCallerFromRegistry, ProcedureScheduleCallerFromRegistry, QueryProcedureBuilder, ResolveIfSet, RunMutationCtx, SchedulerCtx, ServerCaller, Simplify, UnsetMarker, WithHttpRouter, ZCustomCtx, Zid, ZodFromValidatorBase, ZodValidatorFromConvex, 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, inferApiInputs, inferApiOutputs, 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 };
5
+ export { ActionProcedureBuilder, AnyMiddleware, AnyMiddlewareBuilder, CRPCError, CRPCErrorCode, CRPCErrorData, CRPCFunctionTypeHint, CRPCHonoHandler, CRPCHttpRouter, CRPC_ERROR_CODES_BY_KEY, CRPC_ERROR_CODE_TO_HTTP, CallerMeta, CallerOpts, ConvexContext, ConvexValidatorFromZod, ConvexValidatorFromZodOutput, CreateEnvOptions, CreateProcedureCallerFactoryOptions, CustomBuilder, GeneratedProcedureRegistry, GeneratedProcedureRegistryEntry, GeneratedRegistryCallerFactory, GeneratedRegistryCallerForContext, GeneratedRegistryHandlerFactory, GeneratedRegistryHandlerForContext, GenericCtx, GetRawInputFn, HttpActionConstructor, HttpActionHandler, HttpHandlerOpts, HttpMethod, HttpProcedure, HttpProcedureBuilder, HttpProcedureBuilderDef, HttpRouteDefinition, HttpRouterDef, HttpRouterRecord, HttpRouterWithHono, InferHttpInput, IntersectIfDefined, LazyCaller, MergeZodObjects, MiddlewareBuilder, MiddlewareFunction, MiddlewareMarker, MiddlewareNext, MiddlewareProcedureInfo, MiddlewareProcedureType, MiddlewareResult, MutationProcedureBuilder, Overwrite, ProcedureActionCallerFromRegistry, ProcedureBuilder, ProcedureCaller, ProcedureCallerFromRegistry, ProcedureDefinition, ProcedureFromFunctionReference, ProcedureMeta, ProcedureNameEntry, ProcedureNameLookup, ProcedureSchedulableCallerFromRegistry, ProcedureScheduleCallerFromRegistry, QueryProcedureBuilder, ResolveIfSet, RunMutationCtx, RuntimeEnv, SchedulerCtx, ServerCaller, Simplify, UnsetMarker, WithHttpRouter, ZCustomCtx, Zid, ZodFromValidatorBase, ZodValidatorFromConvex, 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, inferApiInputs, inferApiOutputs, 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 };
@@ -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-N3nBOlI2.js";
2
2
  import { n as createLazyCaller, r as createServerCaller, t as createCallerFactory } from "../caller-factory-NEfgD5E0.js";
3
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-DBgto1yn.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-DplSC7Us.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-9m6NBxQu.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 };
@@ -2048,7 +2048,7 @@ var ConvexQueryClient = class {
2048
2048
  };
2049
2049
  if (result.ok) {
2050
2050
  const existingData = this.queryClient.getQueryData(queryKey);
2051
- if (result.value !== null && result.value !== void 0 || !(existingData !== null && existingData !== void 0)) this.queryClient.setQueryData(queryKey, this.transformer.output.deserialize(result.value));
2051
+ if (result.value !== void 0 || !(existingData !== void 0)) this.queryClient.setQueryData(queryKey, this.transformer.output.deserialize(result.value));
2052
2052
  } else {
2053
2053
  const { error } = result;
2054
2054
  const authState = this.getAuthState();
package/dist/watcher.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { Dt as generateMeta, F as resolveRunDeps, Ot as getConvexConfig, j as resolveConfiguredBackend, kt as logger, q as withLocalCodegenEnv } from "./backend-core-B091CyHN.mjs";
2
+ import { Dt as generateMeta, F as resolveRunDeps, Ot as getConvexConfig, j as resolveConfiguredBackend, kt as logger, q as withLocalCodegenEnv } from "./backend-core-BA0CgHrL.mjs";
3
3
  import path from "node:path";
4
4
  import { fileURLToPath } from "node:url";
5
5
 
@@ -3992,11 +3992,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
3992
3992
  readonly aggregate_extrema: ConvexTableWithColumns<{
3993
3993
  name: "aggregate_extrema";
3994
3994
  columns: {
3995
- value: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
3996
- _: {
3997
- $type: convex_values0.Value;
3998
- };
3999
- } & {
3995
+ count: ConvexNumberBuilderInitial<""> & {
4000
3996
  _: {
4001
3997
  notNull: true;
4002
3998
  };
@@ -4006,10 +4002,14 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4006
4002
  };
4007
4003
  } & {
4008
4004
  _: {
4009
- fieldName: "value";
4005
+ fieldName: "count";
4010
4006
  };
4011
4007
  };
4012
- count: ConvexNumberBuilderInitial<""> & {
4008
+ value: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
4009
+ _: {
4010
+ $type: convex_values0.Value;
4011
+ };
4012
+ } & {
4013
4013
  _: {
4014
4014
  notNull: true;
4015
4015
  };
@@ -4019,7 +4019,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4019
4019
  };
4020
4020
  } & {
4021
4021
  _: {
4022
- fieldName: "count";
4022
+ fieldName: "value";
4023
4023
  };
4024
4024
  };
4025
4025
  updatedAt: ConvexNumberBuilderInitial<""> & {
@@ -4411,22 +4411,22 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
4411
4411
  fieldName: "status";
4412
4412
  };
4413
4413
  };
4414
- cursor: ConvexTextBuilderInitial<""> & {
4414
+ direction: ConvexTextBuilderInitial<""> & {
4415
4415
  _: {
4416
4416
  tableName: "migration_state";
4417
4417
  };
4418
4418
  } & {
4419
4419
  _: {
4420
- fieldName: "cursor";
4420
+ fieldName: "direction";
4421
4421
  };
4422
4422
  };
4423
- direction: ConvexTextBuilderInitial<""> & {
4423
+ cursor: ConvexTextBuilderInitial<""> & {
4424
4424
  _: {
4425
4425
  tableName: "migration_state";
4426
4426
  };
4427
4427
  } & {
4428
4428
  _: {
4429
- fieldName: "direction";
4429
+ fieldName: "cursor";
4430
4430
  };
4431
4431
  };
4432
4432
  updatedAt: ConvexNumberBuilderInitial<""> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitcn",
3
- "version": "0.15.1",
3
+ "version": "0.15.4",
4
4
  "description": "kitcn - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",
@@ -387,6 +387,7 @@ All from `kitcn/react`:
387
387
  <ConvexAuthProvider
388
388
  client={convex}
389
389
  authClient={authClient}
390
+ convexQueryClient={convexQueryClient} // when using TanStack Query
390
391
  initialToken={token} // from SSR (caller.getToken())
391
392
  onMutationUnauthorized={() => router.push('/login')}
392
393
  onQueryUnauthorized={({ queryName }) => console.log(`Unauth: ${queryName}`)}
@@ -113,37 +113,32 @@ function QueryProvider({ children }) {
113
113
  **With auth** — swap `ConvexProvider` for `ConvexAuthProvider`:
114
114
  ```tsx
115
115
  import { ConvexAuthProvider } from 'kitcn/auth/client';
116
- import { ConvexReactClient, getConvexQueryClientSingleton, getQueryClientSingleton, useAuthStore } from 'kitcn/react';
116
+ import { ConvexReactClient, getConvexQueryClientSingleton, getQueryClientSingleton } from 'kitcn/react';
117
117
 
118
118
  const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);
119
119
 
120
120
  export function AppConvexProvider({ children, token }: { children: ReactNode; token?: string }) {
121
121
  const router = useRouter();
122
+ const queryClient = getQueryClientSingleton(createQueryClient);
123
+ const convexQueryClient = getConvexQueryClientSingleton({ convex, queryClient });
124
+
122
125
  return (
123
126
  <ConvexAuthProvider
124
127
  authClient={authClient}
125
128
  client={convex}
129
+ convexQueryClient={convexQueryClient}
126
130
  initialToken={token}
127
131
  onMutationUnauthorized={() => router.push('/login')}
128
132
  onQueryUnauthorized={() => router.push('/login')}
129
133
  >
130
- <QueryProvider>{children}</QueryProvider>
134
+ <QueryClientProvider client={queryClient}>
135
+ <CRPCProvider convexClient={convex} convexQueryClient={convexQueryClient}>
136
+ {children}
137
+ </CRPCProvider>
138
+ </QueryClientProvider>
131
139
  </ConvexAuthProvider>
132
140
  );
133
141
  }
134
-
135
- function QueryProvider({ children }) {
136
- const authStore = useAuthStore(); // pass to singleton
137
- const queryClient = getQueryClientSingleton(createQueryClient);
138
- const convexQueryClient = getConvexQueryClientSingleton({ authStore, convex, queryClient });
139
- return (
140
- <QueryClientProvider client={queryClient}>
141
- <CRPCProvider convexClient={convex} convexQueryClient={convexQueryClient}>
142
- {children}
143
- </CRPCProvider>
144
- </QueryClientProvider>
145
- );
146
- }
147
142
  ```
148
143
 
149
144
  ### Singleton Helpers
@@ -156,7 +151,7 @@ function QueryProvider({ children }) {
156
151
  `getConvexQueryClientSingleton` options:
157
152
  - `convex` — ConvexReactClient
158
153
  - `queryClient` — TanStack QueryClient
159
- - `authStore` — from `useAuthStore()` (auth apps only)
154
+ - `authStore` — optional manual auth-store bridge
160
155
  - `unsubscribeDelay` — ms before unsubscribing after unmount (default 3000). Covers StrictMode + quick back-nav.
161
156
 
162
157
  ### ConvexQueryClient (Bridge)
@@ -119,7 +119,6 @@ import {
119
119
  ConvexReactClient,
120
120
  getConvexQueryClientSingleton,
121
121
  getQueryClientSingleton,
122
- useAuthStore,
123
122
  } from "kitcn/react";
124
123
  import type { ReactNode } from "react";
125
124
 
@@ -136,33 +135,25 @@ export function AppConvexProvider({
136
135
  children: ReactNode;
137
136
  token?: string;
138
137
  }) {
139
- return (
140
- <ConvexAuthProvider
141
- authClient={authClient}
142
- client={convex}
143
- initialToken={token}
144
- >
145
- <QueryProvider>{children}</QueryProvider>
146
- </ConvexAuthProvider>
147
- );
148
- }
149
-
150
- function QueryProvider({ children }: { children: ReactNode }) {
151
- const authStore = useAuthStore();
152
-
153
138
  const queryClient = getQueryClientSingleton(createQueryClient);
154
139
  const convexQueryClient = getConvexQueryClientSingleton({
155
- authStore,
156
140
  convex,
157
141
  queryClient,
158
142
  });
159
143
 
160
144
  return (
161
- <TanstackQueryClientProvider client={queryClient}>
162
- <CRPCProvider convexClient={convex} convexQueryClient={convexQueryClient}>
163
- {children}
164
- </CRPCProvider>
165
- </TanstackQueryClientProvider>
145
+ <ConvexAuthProvider
146
+ authClient={authClient}
147
+ client={convex}
148
+ convexQueryClient={convexQueryClient}
149
+ initialToken={token}
150
+ >
151
+ <TanstackQueryClientProvider client={queryClient}>
152
+ <CRPCProvider convexClient={convex} convexQueryClient={convexQueryClient}>
153
+ {children}
154
+ </CRPCProvider>
155
+ </TanstackQueryClientProvider>
156
+ </ConvexAuthProvider>
166
157
  );
167
158
  }
168
159
  ```