kitcn 0.33.2 → 0.33.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,25 @@
1
1
  # kitcn
2
2
 
3
+ ## 0.33.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#465](https://github.com/udecode/kitcn/pull/465) [`5dc460b`](https://github.com/udecode/kitcn/commit/5dc460ba0ae760ea96dba052496a01ffb61f88c3) Thanks [@tjramage](https://github.com/tjramage)! - ## Patches
8
+
9
+ - Fix spurious internal errors during sessionless social sign-in redirects
10
+ while preserving Convex JWT cookie issuance for authenticated sessions.
11
+
12
+ ## 0.33.3
13
+
14
+ ### Patch Changes
15
+
16
+ - [#464](https://github.com/udecode/kitcn/pull/464) [`ac73cc6`](https://github.com/udecode/kitcn/commit/ac73cc6a9ffcb95a6d4ce89f9ef9a591eeacf883) Thanks [@tjramage](https://github.com/tjramage)! - ## Patches
17
+
18
+ - Fix cRPC client-error guards (`isCRPCClientError`, `isCRPCError`,
19
+ `isCRPCErrorCode`) rejecting errors thrown through other entrypoints such as
20
+ `kitcn/react` and `kitcn/solid`, so deterministic refusals like
21
+ `UNAUTHORIZED` are no longer retried as transport failures.
22
+
3
23
  ## 0.33.2
4
24
 
5
25
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  import { Vn as ConvexTextBuilderInitial, Zt as ConvexTableWithColumns } from "../capabilities-Bxzoofl4.js";
2
- import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-B0kyVGzW.js";
2
+ import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial } from "../where-clause-compiler-D2ifnjjj.js";
3
3
  import * as convex_values0 from "convex/values";
4
4
  import { GenericId, Infer, Value } from "convex/values";
5
5
  import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server";
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { A as CRPCClientError, C as decodeJwtExp, D as readAuthSessionFallbackToken, E as readAuthSessionFallbackData, O as writeAuthSessionFallbackData, T as clearAuthSessionFallback, d as isSessionSyncGraceActive, g as useAuthValue, h as useAuthStore, j as defaultIsUnauthorized, n as AuthProvider, o as ConvexProviderWithAuth$1, s as FetchAccessTokenContext, t as AUTH_SESSION_SYNC_GRACE_MS } from "../../auth-store-BnsWs1xd.js";
2
+ import { A as CRPCClientError, C as decodeJwtExp, D as readAuthSessionFallbackToken, E as readAuthSessionFallbackData, O as writeAuthSessionFallbackData, T as clearAuthSessionFallback, d as isSessionSyncGraceActive, g as useAuthValue, h as useAuthStore, j as defaultIsUnauthorized, n as AuthProvider, o as ConvexProviderWithAuth$1, s as FetchAccessTokenContext, t as AUTH_SESSION_SYNC_GRACE_MS } from "../../auth-store-x3_wvhTR.js";
3
3
  import { useConvexAuth } from "convex/react";
4
4
  import { useCallback, useEffect, useMemo, useRef } from "react";
5
5
  import { jsx } from "react/jsx-runtime";
@@ -1,2 +1,2 @@
1
- import { C as GenericAuthTriggerHandlers, S as GenericAuthTriggerChange, T as defineAuth, b as GenericAuthBeforeResult, i as getGeneratedAuthDisabledReason, n as GeneratedAuthDisabledReasonKind, r as createDisabledAuthRuntime, t as AuthRuntime, w as GenericAuthTriggers, x as GenericAuthDefinition, y as BetterAuthOptionsWithoutDatabase } from "../../generated-contract-disabled-CTUQ9nxL.js";
1
+ import { C as GenericAuthTriggerHandlers, S as GenericAuthTriggerChange, T as defineAuth, b as GenericAuthBeforeResult, i as getGeneratedAuthDisabledReason, n as GeneratedAuthDisabledReasonKind, r as createDisabledAuthRuntime, t as AuthRuntime, w as GenericAuthTriggers, x as GenericAuthDefinition, y as BetterAuthOptionsWithoutDatabase } from "../../generated-contract-disabled-PdNGvNYP.js";
2
2
  export { type AuthRuntime, BetterAuthOptionsWithoutDatabase, type GeneratedAuthDisabledReasonKind, GenericAuthBeforeResult, GenericAuthDefinition, GenericAuthTriggerChange, GenericAuthTriggerHandlers, GenericAuthTriggers, createDisabledAuthRuntime, defineAuth, getGeneratedAuthDisabledReason };
@@ -1,7 +1,7 @@
1
1
  import { a as QueryCtxWithPreferredOrmQueryTable, n as LookupByIdResultByCtx, t as DocByCtx } from "../query-context-BkNjkDCk.js";
2
2
  import { t as GetAuth } from "../types-ex0-J-SC.js";
3
3
  import { t as GenericCtx } from "../context-utils-Cbv4r0AA.js";
4
- import { C as GenericAuthTriggerHandlers, S as GenericAuthTriggerChange, T as defineAuth, _ as updateManyHandler, a as AuthFunctions, b as GenericAuthBeforeResult, c as consumeOneHandler, d as createHandler, f as deleteManyHandler, g as incrementOneHandler, h as findOneHandler, i as getGeneratedAuthDisabledReason, l as countHandler, m as findManyHandler, n as GeneratedAuthDisabledReasonKind, o as Triggers, p as deleteOneHandler, r as createDisabledAuthRuntime, s as createClient, t as AuthRuntime, u as createApi, v as updateOneHandler, w as GenericAuthTriggers, x as GenericAuthDefinition, y as BetterAuthOptionsWithoutDatabase } from "../generated-contract-disabled-CTUQ9nxL.js";
4
+ import { C as GenericAuthTriggerHandlers, S as GenericAuthTriggerChange, T as defineAuth, _ as updateManyHandler, a as AuthFunctions, b as GenericAuthBeforeResult, c as consumeOneHandler, d as createHandler, f as deleteManyHandler, g as incrementOneHandler, h as findOneHandler, i as getGeneratedAuthDisabledReason, l as countHandler, m as findManyHandler, n as GeneratedAuthDisabledReasonKind, o as Triggers, p as deleteOneHandler, r as createDisabledAuthRuntime, s as createClient, t as AuthRuntime, u as createApi, v as updateOneHandler, w as GenericAuthTriggers, x as GenericAuthDefinition, y as BetterAuthOptionsWithoutDatabase } from "../generated-contract-disabled-PdNGvNYP.js";
5
5
  import * as convex_values0 from "convex/values";
6
6
  import { Infer } from "convex/values";
7
7
  import { AuthConfig, DocumentByName, GenericDataModel, GenericMutationCtx, GenericQueryCtx, GenericSchema, PaginationOptions, PaginationResult, SchemaDefinition, TableNamesInDataModel } from "convex/server";
@@ -109,28 +109,28 @@ type AdapterPaginationOptions = PaginationOptions & {
109
109
  };
110
110
  declare const adapterWhereValidator: convex_values0.VObject<{
111
111
  mode?: "sensitive" | "insensitive" | undefined;
112
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
113
112
  connector?: "AND" | "OR" | undefined;
114
- value: string | number | boolean | string[] | number[] | null;
113
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
115
114
  field: string;
115
+ value: string | number | boolean | string[] | number[] | null;
116
116
  }, {
117
117
  connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
118
118
  field: convex_values0.VString<string, "required">;
119
119
  mode: convex_values0.VUnion<"sensitive" | "insensitive" | undefined, [convex_values0.VLiteral<"sensitive", "required">, convex_values0.VLiteral<"insensitive", "required">], "optional", never>;
120
- operator: convex_values0.VUnion<"eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
120
+ operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
121
121
  value: convex_values0.VUnion<string | number | boolean | string[] | number[] | null, [convex_values0.VString<string, "required">, convex_values0.VFloat64<number, "required">, convex_values0.VBoolean<boolean, "required">, convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">, convex_values0.VArray<number[], convex_values0.VFloat64<number, "required">, "required">, convex_values0.VNull<null, "required">], "required", never>;
122
- }, "required", "mode" | "operator" | "value" | "field" | "connector">;
122
+ }, "required", "mode" | "connector" | "field" | "operator" | "value">;
123
123
  declare const adapterArgsValidator: convex_values0.VObject<{
124
- limit?: number | undefined;
125
124
  where?: {
126
125
  mode?: "sensitive" | "insensitive" | undefined;
127
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
128
126
  connector?: "AND" | "OR" | undefined;
129
- value: string | number | boolean | string[] | number[] | null;
127
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
130
128
  field: string;
129
+ value: string | number | boolean | string[] | number[] | null;
131
130
  }[] | undefined;
132
- select?: string[] | undefined;
131
+ limit?: number | undefined;
133
132
  offset?: number | undefined;
133
+ select?: string[] | undefined;
134
134
  sortBy?: {
135
135
  field: string;
136
136
  direction: "asc" | "desc";
@@ -150,24 +150,24 @@ declare const adapterArgsValidator: convex_values0.VObject<{
150
150
  }, "optional", "field" | "direction">;
151
151
  where: convex_values0.VArray<{
152
152
  mode?: "sensitive" | "insensitive" | undefined;
153
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
154
153
  connector?: "AND" | "OR" | undefined;
155
- value: string | number | boolean | string[] | number[] | null;
154
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
156
155
  field: string;
156
+ value: string | number | boolean | string[] | number[] | null;
157
157
  }[] | undefined, convex_values0.VObject<{
158
158
  mode?: "sensitive" | "insensitive" | undefined;
159
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
160
159
  connector?: "AND" | "OR" | undefined;
161
- value: string | number | boolean | string[] | number[] | null;
160
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
162
161
  field: string;
162
+ value: string | number | boolean | string[] | number[] | null;
163
163
  }, {
164
164
  connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
165
165
  field: convex_values0.VString<string, "required">;
166
166
  mode: convex_values0.VUnion<"sensitive" | "insensitive" | undefined, [convex_values0.VLiteral<"sensitive", "required">, convex_values0.VLiteral<"insensitive", "required">], "optional", never>;
167
- operator: convex_values0.VUnion<"eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
167
+ operator: convex_values0.VUnion<"lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined, [convex_values0.VLiteral<"lt", "required">, convex_values0.VLiteral<"lte", "required">, convex_values0.VLiteral<"gt", "required">, convex_values0.VLiteral<"gte", "required">, convex_values0.VLiteral<"eq", "required">, convex_values0.VLiteral<"in", "required">, convex_values0.VLiteral<"not_in", "required">, convex_values0.VLiteral<"ne", "required">, convex_values0.VLiteral<"contains", "required">, convex_values0.VLiteral<"starts_with", "required">, convex_values0.VLiteral<"ends_with", "required">], "optional", never>;
168
168
  value: convex_values0.VUnion<string | number | boolean | string[] | number[] | null, [convex_values0.VString<string, "required">, convex_values0.VFloat64<number, "required">, convex_values0.VBoolean<boolean, "required">, convex_values0.VArray<string[], convex_values0.VString<string, "required">, "required">, convex_values0.VArray<number[], convex_values0.VFloat64<number, "required">, "required">, convex_values0.VNull<null, "required">], "required", never>;
169
- }, "required", "mode" | "operator" | "value" | "field" | "connector">, "optional">;
170
- }, "required", "limit" | "where" | "model" | "select" | "offset" | "sortBy" | "sortBy.field" | "sortBy.direction">;
169
+ }, "required", "mode" | "connector" | "field" | "operator" | "value">, "optional">;
170
+ }, "required", "model" | "where" | "limit" | "offset" | "select" | "sortBy" | "sortBy.field" | "sortBy.direction">;
171
171
  declare const hasUniqueFields: (betterAuthSchema: BetterAuthDBSchema, model: string, input: Record<string, any>) => boolean;
172
172
  declare const checkUniqueFields: <Schema extends SchemaDefinition<any, any>>(ctx: GenericQueryCtx<GenericDataModel>, schema: Schema, betterAuthSchema: BetterAuthDBSchema, table: string, input: Record<string, any>, doc?: Record<string, any>) => Promise<void>;
173
173
  declare const selectFields: <T extends TableNamesInDataModel<GenericDataModel>, D extends DocumentByName<GenericDataModel, T>>(doc: D | null, select?: string[]) => D | null;
@@ -5,7 +5,7 @@ import { n as createGeneratedFunctionReference, o as isQueryCtx, s as isRunMutat
5
5
  import { i as customQuery, n as customCtx, r as customMutation } from "../customFunctions-X_B4kET8.js";
6
6
  import { C as eq, o as getAggregateIndexes } from "../index-utils-DvK7P6Q1.js";
7
7
  import { c as stream, f as unsetToken, s as mergedStream, t as getByIdWithOrmQueryFallback } from "../query-context-DQLv58LH.js";
8
- import { n as convex } from "../convex-plugin-AbNQl1Sg.js";
8
+ import { n as convex } from "../convex-plugin-UGuLZPyQ.js";
9
9
  import { v } from "convex/values";
10
10
  import { internalActionGeneric, internalMutationGeneric, internalQueryGeneric, paginationOptsValidator } from "convex/server";
11
11
  import { createAdapterFactory } from "better-auth/adapters";
@@ -1,6 +1,6 @@
1
- import { t as getToken } from "../../token-CuJopBdP.js";
2
- import { n as defaultIsUnauthorized } from "../../error-Dyqhgbf6.js";
3
- import { t as createCallerFactory } from "../../caller-factory-C-N540BC.js";
1
+ import { t as getToken } from "../../token-CgIvcEZX.js";
2
+ import { n as defaultIsUnauthorized } from "../../error-CLgc9khF.js";
3
+ import { t as createCallerFactory } from "../../caller-factory-CEKbQdGY.js";
4
4
 
5
5
  //#region src/auth-nextjs/index.ts
6
6
  /** biome-ignore-all lint/suspicious/noExplicitAny: lib */
@@ -1,6 +1,6 @@
1
- import { t as getToken } from "../../../token-CuJopBdP.js";
2
- import { n as defaultIsUnauthorized } from "../../../error-Dyqhgbf6.js";
3
- import { t as createCallerFactory } from "../../../caller-factory-C-N540BC.js";
1
+ import { t as getToken } from "../../../token-CgIvcEZX.js";
2
+ import { n as defaultIsUnauthorized } from "../../../error-CLgc9khF.js";
3
+ import { t as createCallerFactory } from "../../../caller-factory-CEKbQdGY.js";
4
4
  import { stripIndent } from "common-tags";
5
5
  import { getRequest } from "@tanstack/react-start/server";
6
6
  import { ConvexHttpClient } from "convex/browser";
@@ -5,6 +5,13 @@ import { createAtomStore } from "jotai-x";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
 
7
7
  //#region src/crpc/error.ts
8
+ const CLIENT_ERROR_CODES = [
9
+ "UNAUTHORIZED",
10
+ "FORBIDDEN",
11
+ "NOT_FOUND",
12
+ "BAD_REQUEST",
13
+ "TOO_MANY_REQUESTS"
14
+ ];
8
15
  /**
9
16
  * Client-side CRPC error.
10
17
  * Mirrors backend CRPCError pattern with typed error codes.
@@ -19,8 +26,16 @@ var CRPCClientError = class extends Error {
19
26
  this.functionName = opts.functionName;
20
27
  }
21
28
  };
22
- /** Type guard for CRPCClientError */
23
- const isCRPCClientError = (error) => error instanceof CRPCClientError;
29
+ /**
30
+ * Type guard for CRPCClientError.
31
+ * Checks shape, not constructor: package entrypoints bundle separate copies
32
+ * of the class, so `instanceof` fails across them.
33
+ */
34
+ const isCRPCClientError = (error) => {
35
+ if (!(error instanceof Error)) return false;
36
+ const candidate = error;
37
+ return candidate.name === "CRPCClientError" && CLIENT_ERROR_CODES.includes(candidate.code) && typeof candidate.functionName === "string" && typeof candidate.message === "string";
38
+ };
24
39
  /** Default unauthorized detection - checks UNAUTHORIZED code */
25
40
  const defaultIsUnauthorized = (error) => {
26
41
  if (!error || typeof error !== "object") return false;
@@ -1,4 +1,4 @@
1
- import { n as defaultIsUnauthorized } from "./error-Dyqhgbf6.js";
1
+ import { n as defaultIsUnauthorized } from "./error-CLgc9khF.js";
2
2
  import { i as getFunctionType, n as getFuncRef, t as buildMetaIndex } from "./meta-utils-Cc7neQOB.js";
3
3
  import { s as getTransformer } from "./transformer-C8lVwHNT.js";
4
4
  import { fetchAction, fetchMutation, fetchQuery } from "convex/nextjs";
@@ -5,6 +5,10 @@ import { jwt } from "better-auth/plugins/jwt";
5
5
 
6
6
  //#region src/auth/internal/convex-plugin.ts
7
7
  const JWT_COOKIE_NAME = "convex_jwt";
8
+ const getJwtCookieToken = async (session, getToken) => {
9
+ if (!session) return;
10
+ return await getToken({ headers: new Headers() });
11
+ };
8
12
  const getJwksAlg = (authProvider) => {
9
13
  const isCustomJwt = "type" in authProvider && authProvider.type === "customJwt";
10
14
  if (isCustomJwt && authProvider.algorithm !== "RS256") throw new Error("Only RS256 is supported for custom JWT with Better Auth");
@@ -162,19 +166,22 @@ const convex = (opts) => {
162
166
  return Boolean(ctx.path?.startsWith("/sign-in") || ctx.path?.startsWith("/sign-up") || ctx.path?.startsWith("/callback") || ctx.path?.startsWith("/oauth2/callback") || ctx.path?.startsWith("/magic-link/verify") || ctx.path?.startsWith("/email-otp/verify-email") || ctx.path?.startsWith("/phone-number/verify") || ctx.path?.startsWith("/siwe/verify") || ctx.path?.startsWith("/update-session") || ctx.path?.startsWith("/get-session") && ctx.context.session);
163
167
  },
164
168
  handler: createAuthMiddleware(async (ctx) => {
169
+ if (!(ctx.context.session ?? ctx.context.newSession)) return;
165
170
  const originalSession = ctx.context.session;
166
171
  try {
167
172
  ctx.context.session = ctx.context.session ?? ctx.context.newSession;
168
- const { token } = await jwt$1.endpoints.getToken({
173
+ const tokenResponse = await getJwtCookieToken(ctx.context.session, async ({ headers }) => await jwt$1.endpoints.getToken({
169
174
  ...ctx,
170
175
  asResponse: false,
171
- headers: {},
176
+ headers,
172
177
  method: "GET",
173
178
  returnHeaders: false,
174
179
  returnStatus: false
175
- });
176
- const jwtCookie = ctx.context.createAuthCookie(JWT_COOKIE_NAME, { maxAge: jwtExpirationSeconds });
177
- ctx.setCookie(jwtCookie.name, token, jwtCookie.attributes);
180
+ }));
181
+ if (tokenResponse) {
182
+ const jwtCookie = ctx.context.createAuthCookie(JWT_COOKIE_NAME, { maxAge: jwtExpirationSeconds });
183
+ ctx.setCookie(jwtCookie.name, tokenResponse.token, jwtCookie.attributes);
184
+ }
178
185
  } catch (_error) {}
179
186
  ctx.context.session = originalSession;
180
187
  })
@@ -32,10 +32,11 @@ declare class AuthMutationError extends Error {
32
32
  declare function isAuthMutationError(error: unknown): error is AuthMutationError;
33
33
  //#endregion
34
34
  //#region src/crpc/error.d.ts
35
+ declare const CLIENT_ERROR_CODES: readonly ["UNAUTHORIZED", "FORBIDDEN", "NOT_FOUND", "BAD_REQUEST", "TOO_MANY_REQUESTS"];
35
36
  /**
36
37
  * Client error codes (subset of CRPC codes for client-side use)
37
38
  */
38
- type ClientErrorCode = 'UNAUTHORIZED' | 'FORBIDDEN' | 'NOT_FOUND' | 'BAD_REQUEST' | 'TOO_MANY_REQUESTS';
39
+ type ClientErrorCode = (typeof CLIENT_ERROR_CODES)[number];
39
40
  /**
40
41
  * Client-side CRPC error.
41
42
  * Mirrors backend CRPCError pattern with typed error codes.
@@ -50,7 +51,11 @@ declare class CRPCClientError extends Error {
50
51
  message?: string;
51
52
  });
52
53
  }
53
- /** Type guard for CRPCClientError */
54
+ /**
55
+ * Type guard for CRPCClientError.
56
+ * Checks shape, not constructor: package entrypoints bundle separate copies
57
+ * of the class, so `instanceof` fails across them.
58
+ */
54
59
  declare const isCRPCClientError: (error: unknown) => error is CRPCClientError;
55
60
  /**
56
61
  * Unified check for any deterministic CRPC error (Convex or HTTP).
@@ -1,4 +1,4 @@
1
- import { a as isCRPCErrorCode, i as isCRPCError, n as defaultIsUnauthorized, r as isCRPCClientError, t as CRPCClientError } from "../error-Dyqhgbf6.js";
1
+ import { a as isCRPCErrorCode, i as isCRPCError, n as defaultIsUnauthorized, r as isCRPCClientError, t as CRPCClientError } from "../error-CLgc9khF.js";
2
2
  import { a as defaultCRPCTransformer, c as identityTransformer, i as decodeWire, n as createTaggedTransformer, o as encodeWire, r as dateWireCodec, s as getTransformer, t as DATE_CODEC_TAG } from "../transformer-C8lVwHNT.js";
3
3
  import { a as buildSearchParams, c as HTTP_DEFAULT_STALE_TIME, d as buildHttpQueryPrefixKey, f as isHttpClientError, i as RESERVED_KEYS, l as HttpClientError, n as convexInfiniteQueryOptions, o as executeHttpRequest, r as convexQuery, s as replaceUrlParam, t as convexAction, u as buildHttpQueryKey } from "../query-options-DGG93--5.js";
4
4
 
@@ -1,4 +1,11 @@
1
1
  //#region src/crpc/error.ts
2
+ const CLIENT_ERROR_CODES = [
3
+ "UNAUTHORIZED",
4
+ "FORBIDDEN",
5
+ "NOT_FOUND",
6
+ "BAD_REQUEST",
7
+ "TOO_MANY_REQUESTS"
8
+ ];
2
9
  /**
3
10
  * Client-side CRPC error.
4
11
  * Mirrors backend CRPCError pattern with typed error codes.
@@ -13,14 +20,22 @@ var CRPCClientError = class extends Error {
13
20
  this.functionName = opts.functionName;
14
21
  }
15
22
  };
16
- /** Type guard for CRPCClientError */
17
- const isCRPCClientError = (error) => error instanceof CRPCClientError;
23
+ /**
24
+ * Type guard for CRPCClientError.
25
+ * Checks shape, not constructor: package entrypoints bundle separate copies
26
+ * of the class, so `instanceof` fails across them.
27
+ */
28
+ const isCRPCClientError = (error) => {
29
+ if (!(error instanceof Error)) return false;
30
+ const candidate = error;
31
+ return candidate.name === "CRPCClientError" && CLIENT_ERROR_CODES.includes(candidate.code) && typeof candidate.functionName === "string" && typeof candidate.message === "string";
32
+ };
18
33
  /**
19
34
  * Unified check for any deterministic CRPC error (Convex or HTTP).
20
35
  * Use in retry logic to skip retrying client errors (4xx).
21
36
  */
22
37
  const isCRPCError = (error) => {
23
- if (error instanceof CRPCClientError) return true;
38
+ if (isCRPCClientError(error)) return true;
24
39
  if (error instanceof Error && error.name === "HttpClientError" && "status" in error && typeof error.status === "number") return error.status < 500;
25
40
  return false;
26
41
  };
@@ -199,20 +199,20 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
199
199
  count: convex_server0.RegisteredQuery<"internal", {
200
200
  where?: {
201
201
  mode?: "sensitive" | "insensitive" | undefined;
202
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
203
202
  connector?: "AND" | "OR" | undefined;
204
- value: string | number | boolean | string[] | number[] | null;
203
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
205
204
  field: string;
205
+ value: string | number | boolean | string[] | number[] | null;
206
206
  }[] | undefined;
207
207
  model: string;
208
208
  }, Promise<number | null>>;
209
209
  consumeOne: convex_server0.RegisteredMutation<"internal", {
210
210
  input: {
211
211
  where?: {
212
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
213
212
  connector?: "AND" | "OR" | undefined;
214
- value: string | number | boolean | string[] | number[] | null;
213
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
215
214
  field: string;
215
+ value: string | number | boolean | string[] | number[] | null;
216
216
  }[] | undefined;
217
217
  model: string;
218
218
  } | {
@@ -235,26 +235,26 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
235
235
  };
236
236
  }, Promise<any>>;
237
237
  deleteMany: convex_server0.RegisteredMutation<"internal", {
238
- paginationOpts: {
239
- id?: number;
240
- endCursor?: string | null;
241
- maximumRowsRead?: number;
242
- maximumBytesRead?: number;
243
- numItems: number;
244
- cursor: string | null;
245
- };
246
238
  input: {
247
239
  where?: {
248
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
249
240
  connector?: "AND" | "OR" | undefined;
250
- value: string | number | boolean | string[] | number[] | null;
241
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
251
242
  field: string;
243
+ value: string | number | boolean | string[] | number[] | null;
252
244
  }[] | undefined;
253
245
  model: string;
254
246
  } | {
255
247
  where?: any[] | undefined;
256
248
  model: string;
257
249
  };
250
+ paginationOpts: {
251
+ id?: number;
252
+ endCursor?: string | null;
253
+ maximumRowsRead?: number;
254
+ maximumBytesRead?: number;
255
+ numItems: number;
256
+ cursor: string | null;
257
+ };
258
258
  }, Promise<{
259
259
  count: number;
260
260
  ids: any[];
@@ -266,10 +266,10 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
266
266
  deleteOne: convex_server0.RegisteredMutation<"internal", {
267
267
  input: {
268
268
  where?: {
269
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
270
269
  connector?: "AND" | "OR" | undefined;
271
- value: string | number | boolean | string[] | number[] | null;
270
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
272
271
  field: string;
272
+ value: string | number | boolean | string[] | number[] | null;
273
273
  }[] | undefined;
274
274
  model: string;
275
275
  } | {
@@ -278,20 +278,21 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
278
278
  };
279
279
  }, Promise<Record<string, unknown> | undefined>>;
280
280
  findMany: convex_server0.RegisteredQuery<"internal", {
281
- limit?: number | undefined;
282
281
  join?: any;
283
282
  where?: {
284
283
  mode?: "sensitive" | "insensitive" | undefined;
285
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
286
284
  connector?: "AND" | "OR" | undefined;
287
- value: string | number | boolean | string[] | number[] | null;
285
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
288
286
  field: string;
287
+ value: string | number | boolean | string[] | number[] | null;
289
288
  }[] | undefined;
289
+ limit?: number | undefined;
290
290
  offset?: number | undefined;
291
291
  sortBy?: {
292
292
  field: string;
293
293
  direction: "asc" | "desc";
294
294
  } | undefined;
295
+ model: string;
295
296
  paginationOpts: {
296
297
  id?: number;
297
298
  endCursor?: string | null;
@@ -300,16 +301,15 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
300
301
  numItems: number;
301
302
  cursor: string | null;
302
303
  };
303
- model: string;
304
304
  }, Promise<PaginationResult<convex_server0.GenericDocument>>>;
305
305
  findOne: convex_server0.RegisteredQuery<"internal", {
306
306
  join?: any;
307
307
  where?: {
308
308
  mode?: "sensitive" | "insensitive" | undefined;
309
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
310
309
  connector?: "AND" | "OR" | undefined;
311
- value: string | number | boolean | string[] | number[] | null;
310
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
312
311
  field: string;
312
+ value: string | number | boolean | string[] | number[] | null;
313
313
  }[] | undefined;
314
314
  select?: string[] | undefined;
315
315
  model: string;
@@ -319,10 +319,10 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
319
319
  input: {
320
320
  where?: {
321
321
  mode?: "sensitive" | "insensitive" | undefined;
322
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
323
322
  connector?: "AND" | "OR" | undefined;
324
- value: string | number | boolean | string[] | number[] | null;
323
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
325
324
  field: string;
325
+ value: string | number | boolean | string[] | number[] | null;
326
326
  }[] | undefined;
327
327
  set?: Record<string, any> | undefined;
328
328
  model: string;
@@ -331,31 +331,31 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
331
331
  }, Promise<any>>;
332
332
  rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
333
333
  updateMany: convex_server0.RegisteredMutation<"internal", {
334
- paginationOpts: {
335
- id?: number;
336
- endCursor?: string | null;
337
- maximumRowsRead?: number;
338
- maximumBytesRead?: number;
339
- numItems: number;
340
- cursor: string | null;
341
- };
342
334
  input: {
343
335
  where?: {
344
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
345
336
  connector?: "AND" | "OR" | undefined;
346
- value: string | number | boolean | string[] | number[] | null;
337
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
347
338
  field: string;
339
+ value: string | number | boolean | string[] | number[] | null;
348
340
  }[] | undefined;
341
+ model: string;
349
342
  update: {
350
343
  [x: string]: unknown;
351
344
  [x: number]: unknown;
352
345
  [x: symbol]: unknown;
353
346
  };
354
- model: string;
355
347
  } | {
356
348
  where?: any[] | undefined;
357
- update: any;
358
349
  model: string;
350
+ update: any;
351
+ };
352
+ paginationOpts: {
353
+ id?: number;
354
+ endCursor?: string | null;
355
+ maximumRowsRead?: number;
356
+ maximumBytesRead?: number;
357
+ numItems: number;
358
+ cursor: string | null;
359
359
  };
360
360
  }, Promise<{
361
361
  count: number;
@@ -368,21 +368,21 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
368
368
  updateOne: convex_server0.RegisteredMutation<"internal", {
369
369
  input: {
370
370
  where?: {
371
- operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
372
371
  connector?: "AND" | "OR" | undefined;
373
- value: string | number | boolean | string[] | number[] | null;
372
+ operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
374
373
  field: string;
374
+ value: string | number | boolean | string[] | number[] | null;
375
375
  }[] | undefined;
376
+ model: string;
376
377
  update: {
377
378
  [x: string]: unknown;
378
379
  [x: number]: unknown;
379
380
  [x: symbol]: unknown;
380
381
  };
381
- model: string;
382
382
  } | {
383
383
  where?: any[] | undefined;
384
- update: any;
385
384
  model: string;
385
+ update: any;
386
386
  };
387
387
  }, Promise<any>>;
388
388
  };
@@ -1,5 +1,5 @@
1
1
  import { $n as TableName, $t as OrmLifecycleChange, An as ConvexCheckBuilder, At as UpdateSet, Bn as ConvexTextBuilder, Br as IsPrimaryKey, Bt as RelationsBuilderColumnBase, C as MigrationStep, Cn as ConvexVectorIndexConfig, Cr as not, Ct as OrderByClause, D as defineMigration, Dn as searchIndex, Dr as startsWith, Dt as ReturningAll, E as buildMigrationPlan, En as rankIndex, Er as or, Et as PredicateWhereIndexConfig, Fn as ConvexUniqueConstraintBuilderOn, Fr as ColumnBuilderTypeConfig, Ft as ExtractTablesFromSchema, Gn as Columns, Gt as TablesRelationalConfig, H as RlsMode, Hn as text, Hr as NotNull, In as ConvexUniqueConstraintConfig, Ir as ColumnBuilderWithTableName, It as ExtractTablesWithRelations, Jn as OrmSchemaExtensionTables, Jt as ConvexDeletionBuilder, Kt as defineRelations, Ln as check, Lr as ColumnDataType, Lt as ManyConfig, M as DatabaseWithQuery, Mn as ConvexForeignKeyBuilder, Mr as ColumnBuilder, Mt as VectorSearchProvider, N as OrmReader$1, Nn as ConvexForeignKeyConfig, Nr as ColumnBuilderBaseConfig, Nt as unsetToken, O as defineMigrationSet, On as uniqueIndex, Ot as ReturningResult, P as OrmWriter$1, Pn as ConvexUniqueConstraintBuilder, Pr as ColumnBuilderRuntimeConfig, Qn as OrmSchemaTriggers, Qt as DiscriminatorBuilderConfig, Rn as foreignKey, Rr as DrizzleEntity, Rt as OneConfig, S as MigrationStateMap, Sn as ConvexVectorIndexBuilderOn, Sr as ne, St as MutationRunMode, T as MigrationWriteMode, Tn as index, Tr as notInArray, Tt as PaginatedResult, U as EdgeMetadata, V as RlsContext, Vn as ConvexTextBuilderInitial, Vr as IsUnique, Vt as RelationsBuilderColumnConfig, W as extractRelationsConfig, Wn as Brand, Wt as TableRelationalConfig, Xn as OrmSchemaExtensions, Xt as ConvexTable, Yt as ConvexDeletionConfig, Zn as OrmSchemaRelations, Zt as ConvexTableWithColumns, _ as MigrationManifestEntry, _n as ConvexRankIndexBuilderOn, _r as isNotNull, _t as MutationExecutionMode, an as RlsPolicy, ar as UnaryExpression, at as BuildRelationResult, b as MigrationRunStatus, bn as ConvexSearchIndexConfig, br as lt, bt as MutationResult, cn as rlsPolicy, cr as contains, ct as DBQueryConfig, d as MigrationAppliedState, dn as rlsRole, dr as fieldRef, dt as InferInsertModel, en as OrmLifecycleOperation, er as BinaryExpression, f as MigrationDefinition, fn as ConvexAggregateIndexBuilder, fr as gt, ft as InferModelFromColumns, g as MigrationDriftIssue, gn as ConvexRankIndexBuilder, gr as isFieldReference, gt as MutationExecuteResult, h as MigrationDocContext, hn as ConvexIndexBuilderOn, hr as inArray, ht as MutationExecuteConfig, i as OrmMigrationCapability, in as discriminator, ir as LogicalExpression, it as BuildQueryResult, j as DatabaseWithMutations, jn as ConvexCheckConfig, jr as AnyColumn, jt as VectorQueryConfig, k as detectMigrationDrift, kn as vectorIndex, kr as SystemFields, kt as ReturningSelection, ln as RlsRole, lr as endsWith, lt as FilterOperators, m as MigrationDoc, mn as ConvexIndexBuilder, mr as ilike, mt as InsertValue, n as OrmCapabilities, nn as convexTable, nr as FieldReference, nt as AggregateFieldValue, on as RlsPolicyConfig, or as and, ot as CountConfig, p as MigrationDirection, pn as ConvexAggregateIndexBuilderOn, pr as gte, pt as InferSelectModel, qt as defineRelationsPart, r as OrmCapability, rn as deletion, rr as FilterExpression, rt as AggregateResult, sn as RlsPolicyToOption, sr as between, st as CountResult, t as OrmAggregateCapability, tn as TableConfig, tr as ExpressionVisitor, tt as AggregateConfig, un as RlsRoleConfig, ur as eq, ut as GetColumnData, v as MigrationMigrateOne, vn as ConvexSearchIndexBuilder, vr as isNull, vt as MutationPaginateConfig, w as MigrationTableName, wn as aggregateIndex, wr as notBetween, wt as OrderDirection, x as MigrationSet, xn as ConvexVectorIndexBuilder, xr as lte, xt as MutationReturning, y as MigrationPlan, yn as ConvexSearchIndexBuilderOn, yr as like, yt as MutationPaginatedResult, zn as unique, zr as HasDefault, zt as RelationsBuilder } from "../capabilities-Bxzoofl4.js";
2
- import { $ as OrmClientWithApi$1, A as ConvexDateMode, B as ConvexBytesBuilderInitial, C as ConvexNumberBuilderInitial, D as id, E as ConvexIdBuilderInitial, F as custom, G as ConvexBigIntBuilder, H as ConvexBooleanBuilder, I as json, J as CreateOrmOptions, K as ConvexBigIntBuilderInitial, L as objectOf, M as ConvexCustomBuilder, N as ConvexCustomBuilderInitial, O as ConvexDateBuilder, P as arrayOf, Q as OrmClientBase$1, R as unionOf, S as ConvexNumberBuilder, St as defineTriggers, T as ConvexIdBuilder, U as ConvexBooleanBuilderInitial, V as bytes, W as boolean, X as GenericOrmCtx$1, Y as GenericOrm$1, Z as OrmApiResult, _ as ConvexTimestampMode, _t as OrmBeforeResult, a as requireSchemaRelations, at as ScheduledMutationBatchArgs, b as ConvexTextEnumBuilderInitial, bt as OrmTriggerContext, c as TableConfigResult, ct as scheduledDeleteFactory, d as OrmNotFoundError, et as OrmFunctions, f as ConvexVectorBuilder, g as ConvexTimestampBuilderInitial, gt as defineSchemaExtension, h as ConvexTimestampBuilder, ht as SchemaExtension, i as getSchemaTriggers, it as createOrm, j as date, k as ConvexDateBuilderInitial, l as getTableColumns, m as vector, n as defineSchema, nt as OrmWriterCtx, o as asc, ot as scheduledMutationBatchFactory, p as ConvexVectorBuilderInitial, q as bigint, r as getSchemaRelations, rt as ResolveOrmSchema, s as desc, st as ScheduledDeleteArgs, t as WhereClauseResult, tt as OrmReaderCtx, u as getTableConfig, v as timestamp, vt as OrmTableTriggers, w as integer, x as textEnum, xt as OrmTriggers, y as ConvexTextEnumBuilder, yt as OrmTriggerChange, z as ConvexBytesBuilder } from "../where-clause-compiler-B0kyVGzW.js";
2
+ import { $ as OrmClientWithApi$1, A as ConvexDateMode, B as ConvexBytesBuilderInitial, C as ConvexNumberBuilderInitial, D as id, E as ConvexIdBuilderInitial, F as custom, G as ConvexBigIntBuilder, H as ConvexBooleanBuilder, I as json, J as CreateOrmOptions, K as ConvexBigIntBuilderInitial, L as objectOf, M as ConvexCustomBuilder, N as ConvexCustomBuilderInitial, O as ConvexDateBuilder, P as arrayOf, Q as OrmClientBase$1, R as unionOf, S as ConvexNumberBuilder, St as defineTriggers, T as ConvexIdBuilder, U as ConvexBooleanBuilderInitial, V as bytes, W as boolean, X as GenericOrmCtx$1, Y as GenericOrm$1, Z as OrmApiResult, _ as ConvexTimestampMode, _t as OrmBeforeResult, a as requireSchemaRelations, at as ScheduledMutationBatchArgs, b as ConvexTextEnumBuilderInitial, bt as OrmTriggerContext, c as TableConfigResult, ct as scheduledDeleteFactory, d as OrmNotFoundError, et as OrmFunctions, f as ConvexVectorBuilder, g as ConvexTimestampBuilderInitial, gt as defineSchemaExtension, h as ConvexTimestampBuilder, ht as SchemaExtension, i as getSchemaTriggers, it as createOrm, j as date, k as ConvexDateBuilderInitial, l as getTableColumns, m as vector, n as defineSchema, nt as OrmWriterCtx, o as asc, ot as scheduledMutationBatchFactory, p as ConvexVectorBuilderInitial, q as bigint, r as getSchemaRelations, rt as ResolveOrmSchema, s as desc, st as ScheduledDeleteArgs, t as WhereClauseResult, tt as OrmReaderCtx, u as getTableConfig, v as timestamp, vt as OrmTableTriggers, w as integer, x as textEnum, xt as OrmTriggers, y as ConvexTextEnumBuilder, yt as OrmTriggerChange, z as ConvexBytesBuilder } from "../where-clause-compiler-D2ifnjjj.js";
3
3
  import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-0I-Ik1EN.js";
4
4
  import { a as QueryCtxWithPreferredOrmQueryTable, i as QueryCtxWithOrmQueryTable, n as LookupByIdResultByCtx, o as getByIdWithOrmQueryFallback, r as QueryCtxWithOptionalOrmQueryTable, t as DocByCtx } from "../query-context-BkNjkDCk.js";
5
5
  import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchemaDefinition } from "convex/server";
@@ -1,3 +1,3 @@
1
1
  import { C as MigrationStep, D as defineMigration, E as buildMigrationPlan, O as defineMigrationSet, S as MigrationStateMap, T as MigrationWriteMode, _ as MigrationManifestEntry, a as MAX_STATUS_RUN_LIMIT, b as MigrationRunStatus, c as MigrationRunChunkArgs, d as MigrationAppliedState, f as MigrationDefinition, g as MigrationDriftIssue, h as MigrationDocContext, k as detectMigrationDrift, l as MigrationStatusArgs, m as MigrationDoc, o as MigrationCancelArgs, p as MigrationDirection, s as MigrationRunArgs, u as createMigrationHandlers, v as MigrationMigrateOne, w as MigrationTableName, x as MigrationSet, y as MigrationPlan } from "../../capabilities-Bxzoofl4.js";
2
- import { Ct as migrationCapability, dt as MIGRATION_STORAGE_TABLE_NAMES, ft as injectMigrationStorageTables, lt as MIGRATION_RUN_TABLE, mt as migrationStorageTables, pt as migrationExtension, ut as MIGRATION_STATE_TABLE } from "../../where-clause-compiler-B0kyVGzW.js";
2
+ import { Ct as migrationCapability, dt as MIGRATION_STORAGE_TABLE_NAMES, ft as injectMigrationStorageTables, lt as MIGRATION_RUN_TABLE, mt as migrationStorageTables, pt as migrationExtension, ut as MIGRATION_STATE_TABLE } from "../../where-clause-compiler-D2ifnjjj.js";
3
3
  export { MAX_STATUS_RUN_LIMIT, MIGRATION_RUN_TABLE, MIGRATION_STATE_TABLE, MIGRATION_STORAGE_TABLE_NAMES, type MigrationAppliedState, type MigrationCancelArgs, type MigrationDefinition, type MigrationDirection, type MigrationDoc, type MigrationDocContext, type MigrationDriftIssue, type MigrationManifestEntry, type MigrationMigrateOne, type MigrationPlan, type MigrationRunArgs, type MigrationRunChunkArgs, type MigrationRunStatus, type MigrationSet, type MigrationStateMap, type MigrationStatusArgs, type MigrationStep, type MigrationTableName, type MigrationWriteMode, buildMigrationPlan, createMigrationHandlers, defineMigration, defineMigrationSet, detectMigrationDrift, injectMigrationStorageTables, migrationCapability, migrationExtension, migrationStorageTables };
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { A as CRPCClientError, C as decodeJwtExp, M as isCRPCClientError, O as writeAuthSessionFallbackData, S as useSafeConvexAuth, T as clearAuthSessionFallback, _ as useConvexAuthBridge, a as ConvexAuthRecoveryError, b as useIsAuth, c as MaybeAuthenticated, d as isSessionSyncGraceActive, f as useAuth, g as useAuthValue, h as useAuthStore, i as ConvexAuthBridge, j as defaultIsUnauthorized, k as writeAuthSessionFallbackToken, l as MaybeUnauthenticated, m as useAuthState, n as AuthProvider, o as ConvexProviderWithAuth, p as useAuthGuard, r as Authenticated, s as FetchAccessTokenContext, t as AUTH_SESSION_SYNC_GRACE_MS, u as Unauthenticated, v as useConvexAuthRecovery, w as decodeJwtIdentity, x as useMaybeAuth, y as useFetchAccessToken } from "../auth-store-BnsWs1xd.js";
2
+ import { A as CRPCClientError, C as decodeJwtExp, M as isCRPCClientError, O as writeAuthSessionFallbackData, S as useSafeConvexAuth, T as clearAuthSessionFallback, _ as useConvexAuthBridge, a as ConvexAuthRecoveryError, b as useIsAuth, c as MaybeAuthenticated, d as isSessionSyncGraceActive, f as useAuth, g as useAuthValue, h as useAuthStore, i as ConvexAuthBridge, j as defaultIsUnauthorized, k as writeAuthSessionFallbackToken, l as MaybeUnauthenticated, m as useAuthState, n as AuthProvider, o as ConvexProviderWithAuth, p as useAuthGuard, r as Authenticated, s as FetchAccessTokenContext, t as AUTH_SESSION_SYNC_GRACE_MS, u as Unauthenticated, v as useConvexAuthRecovery, w as decodeJwtIdentity, x as useMaybeAuth, y as useFetchAccessToken } from "../auth-store-x3_wvhTR.js";
3
3
  import { ConvexProvider, ConvexReactClient, ConvexReactClient as ConvexReactClient$1, useAction, useConvex, useMutation } from "convex/react";
4
4
  import { createContext, useCallback, useContext, useEffect, useMemo, useRef, useState } from "react";
5
5
  import { jsx } from "react/jsx-runtime";
package/dist/rsc/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { n as defaultIsUnauthorized } from "../error-Dyqhgbf6.js";
1
+ import { n as defaultIsUnauthorized } from "../error-CLgc9khF.js";
2
2
  import { n as getFuncRef, r as getFunctionMeta, t as buildMetaIndex } from "../meta-utils-Cc7neQOB.js";
3
3
  import { o as encodeWire, s as getTransformer } from "../transformer-C8lVwHNT.js";
4
4
  import { c as HTTP_DEFAULT_STALE_TIME, n as convexInfiniteQueryOptions, o as executeHttpRequest, r as convexQuery, u as buildHttpQueryKey } from "../query-options-DGG93--5.js";
@@ -1,5 +1,5 @@
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
- import { n as createLazyCaller, r as createServerCaller, t as createCallerFactory } from "../caller-factory-C-N540BC.js";
2
+ import { n as createLazyCaller, r as createServerCaller, t as createCallerFactory } from "../caller-factory-CEKbQdGY.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-DDYTlmTB.js";
4
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
 
@@ -8,6 +8,13 @@ import { QueriesObserver, hashKey } from "@tanstack/query-core";
8
8
  import { convexToJson } from "convex/values";
9
9
 
10
10
  //#region src/crpc/error.ts
11
+ const CLIENT_ERROR_CODES = [
12
+ "UNAUTHORIZED",
13
+ "FORBIDDEN",
14
+ "NOT_FOUND",
15
+ "BAD_REQUEST",
16
+ "TOO_MANY_REQUESTS"
17
+ ];
11
18
  /**
12
19
  * Client-side CRPC error.
13
20
  * Mirrors backend CRPCError pattern with typed error codes.
@@ -22,8 +29,16 @@ var CRPCClientError = class extends Error {
22
29
  this.functionName = opts.functionName;
23
30
  }
24
31
  };
25
- /** Type guard for CRPCClientError */
26
- const isCRPCClientError = (error) => error instanceof CRPCClientError;
32
+ /**
33
+ * Type guard for CRPCClientError.
34
+ * Checks shape, not constructor: package entrypoints bundle separate copies
35
+ * of the class, so `instanceof` fails across them.
36
+ */
37
+ const isCRPCClientError = (error) => {
38
+ if (!(error instanceof Error)) return false;
39
+ const candidate = error;
40
+ return candidate.name === "CRPCClientError" && CLIENT_ERROR_CODES.includes(candidate.code) && typeof candidate.functionName === "string" && typeof candidate.message === "string";
41
+ };
27
42
  /** Default unauthorized detection - checks UNAUTHORIZED code */
28
43
  const defaultIsUnauthorized = (error) => {
29
44
  if (!error || typeof error !== "object") return false;
@@ -1,4 +1,4 @@
1
- import { t as JWT_COOKIE_NAME } from "./convex-plugin-AbNQl1Sg.js";
1
+ import { t as JWT_COOKIE_NAME } from "./convex-plugin-UGuLZPyQ.js";
2
2
  import { betterFetch } from "@better-fetch/fetch";
3
3
  import { getSessionCookie } from "better-auth/cookies";
4
4
  import * as jose from "jose";
@@ -120,19 +120,6 @@ declare const migrationStorageTables: {
120
120
  fieldName: "cursor";
121
121
  };
122
122
  };
123
- updatedAt: ConvexNumberBuilderInitial<""> & {
124
- _: {
125
- notNull: true;
126
- };
127
- } & {
128
- _: {
129
- tableName: "migration_state";
130
- };
131
- } & {
132
- _: {
133
- fieldName: "updatedAt";
134
- };
135
- };
136
123
  migrationId: ConvexTextBuilderInitial<""> & {
137
124
  _: {
138
125
  notNull: true;
@@ -203,6 +190,19 @@ declare const migrationStorageTables: {
203
190
  fieldName: "startedAt";
204
191
  };
205
192
  };
193
+ updatedAt: ConvexNumberBuilderInitial<""> & {
194
+ _: {
195
+ notNull: true;
196
+ };
197
+ } & {
198
+ _: {
199
+ tableName: "migration_state";
200
+ };
201
+ } & {
202
+ _: {
203
+ fieldName: "updatedAt";
204
+ };
205
+ };
206
206
  completedAt: ConvexNumberBuilderInitial<""> & {
207
207
  _: {
208
208
  tableName: "migration_state";
@@ -269,7 +269,7 @@ declare const migrationStorageTables: {
269
269
  fieldName: "direction";
270
270
  };
271
271
  };
272
- updatedAt: ConvexNumberBuilderInitial<""> & {
272
+ runId: ConvexTextBuilderInitial<""> & {
273
273
  _: {
274
274
  notNull: true;
275
275
  };
@@ -279,10 +279,10 @@ declare const migrationStorageTables: {
279
279
  };
280
280
  } & {
281
281
  _: {
282
- fieldName: "updatedAt";
282
+ fieldName: "runId";
283
283
  };
284
284
  };
285
- runId: ConvexTextBuilderInitial<""> & {
285
+ startedAt: ConvexNumberBuilderInitial<""> & {
286
286
  _: {
287
287
  notNull: true;
288
288
  };
@@ -292,10 +292,10 @@ declare const migrationStorageTables: {
292
292
  };
293
293
  } & {
294
294
  _: {
295
- fieldName: "runId";
295
+ fieldName: "startedAt";
296
296
  };
297
297
  };
298
- startedAt: ConvexNumberBuilderInitial<""> & {
298
+ updatedAt: ConvexNumberBuilderInitial<""> & {
299
299
  _: {
300
300
  notNull: true;
301
301
  };
@@ -305,7 +305,7 @@ declare const migrationStorageTables: {
305
305
  };
306
306
  } & {
307
307
  _: {
308
- fieldName: "startedAt";
308
+ fieldName: "updatedAt";
309
309
  };
310
310
  };
311
311
  completedAt: ConvexNumberBuilderInitial<""> & {
@@ -1011,7 +1011,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1011
1011
  readonly aggregate_bucket: ConvexTableWithColumns<{
1012
1012
  name: "aggregate_bucket";
1013
1013
  columns: {
1014
- count: ConvexNumberBuilderInitial<""> & {
1014
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1015
1015
  _: {
1016
1016
  notNull: true;
1017
1017
  };
@@ -1021,10 +1021,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1021
1021
  };
1022
1022
  } & {
1023
1023
  _: {
1024
- fieldName: "count";
1024
+ fieldName: "updatedAt";
1025
1025
  };
1026
1026
  };
1027
- updatedAt: ConvexNumberBuilderInitial<""> & {
1027
+ indexName: ConvexTextBuilderInitial<""> & {
1028
1028
  _: {
1029
1029
  notNull: true;
1030
1030
  };
@@ -1034,10 +1034,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1034
1034
  };
1035
1035
  } & {
1036
1036
  _: {
1037
- fieldName: "updatedAt";
1037
+ fieldName: "indexName";
1038
1038
  };
1039
1039
  };
1040
- indexName: ConvexTextBuilderInitial<""> & {
1040
+ count: ConvexNumberBuilderInitial<""> & {
1041
1041
  _: {
1042
1042
  notNull: true;
1043
1043
  };
@@ -1047,7 +1047,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1047
1047
  };
1048
1048
  } & {
1049
1049
  _: {
1050
- fieldName: "indexName";
1050
+ fieldName: "count";
1051
1051
  };
1052
1052
  };
1053
1053
  tableKey: ConvexTextBuilderInitial<""> & {
@@ -1326,7 +1326,11 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1326
1326
  readonly aggregate_extrema: ConvexTableWithColumns<{
1327
1327
  name: "aggregate_extrema";
1328
1328
  columns: {
1329
- count: ConvexNumberBuilderInitial<""> & {
1329
+ value: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
1330
+ _: {
1331
+ $type: convex_values0.Value;
1332
+ };
1333
+ } & {
1330
1334
  _: {
1331
1335
  notNull: true;
1332
1336
  };
@@ -1336,14 +1340,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1336
1340
  };
1337
1341
  } & {
1338
1342
  _: {
1339
- fieldName: "count";
1343
+ fieldName: "value";
1340
1344
  };
1341
1345
  };
1342
- value: ConvexCustomBuilderInitial<"", convex_values0.VAny<any, "required", string>> & {
1343
- _: {
1344
- $type: convex_values0.Value;
1345
- };
1346
- } & {
1346
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1347
1347
  _: {
1348
1348
  notNull: true;
1349
1349
  };
@@ -1353,10 +1353,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1353
1353
  };
1354
1354
  } & {
1355
1355
  _: {
1356
- fieldName: "value";
1356
+ fieldName: "updatedAt";
1357
1357
  };
1358
1358
  };
1359
- updatedAt: ConvexNumberBuilderInitial<""> & {
1359
+ indexName: ConvexTextBuilderInitial<""> & {
1360
1360
  _: {
1361
1361
  notNull: true;
1362
1362
  };
@@ -1366,10 +1366,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1366
1366
  };
1367
1367
  } & {
1368
1368
  _: {
1369
- fieldName: "updatedAt";
1369
+ fieldName: "indexName";
1370
1370
  };
1371
1371
  };
1372
- indexName: ConvexTextBuilderInitial<""> & {
1372
+ count: ConvexNumberBuilderInitial<""> & {
1373
1373
  _: {
1374
1374
  notNull: true;
1375
1375
  };
@@ -1379,7 +1379,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1379
1379
  };
1380
1380
  } & {
1381
1381
  _: {
1382
- fieldName: "indexName";
1382
+ fieldName: "count";
1383
1383
  };
1384
1384
  };
1385
1385
  tableKey: ConvexTextBuilderInitial<""> & {
@@ -1618,7 +1618,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1618
1618
  fieldName: "cursor";
1619
1619
  };
1620
1620
  };
1621
- updatedAt: ConvexNumberBuilderInitial<""> & {
1621
+ processed: ConvexNumberBuilderInitial<""> & {
1622
1622
  _: {
1623
1623
  notNull: true;
1624
1624
  };
@@ -1628,10 +1628,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1628
1628
  };
1629
1629
  } & {
1630
1630
  _: {
1631
- fieldName: "updatedAt";
1631
+ fieldName: "processed";
1632
1632
  };
1633
1633
  };
1634
- processed: ConvexNumberBuilderInitial<""> & {
1634
+ startedAt: ConvexNumberBuilderInitial<""> & {
1635
1635
  _: {
1636
1636
  notNull: true;
1637
1637
  };
@@ -1641,10 +1641,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1641
1641
  };
1642
1642
  } & {
1643
1643
  _: {
1644
- fieldName: "processed";
1644
+ fieldName: "startedAt";
1645
1645
  };
1646
1646
  };
1647
- startedAt: ConvexNumberBuilderInitial<""> & {
1647
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1648
1648
  _: {
1649
1649
  notNull: true;
1650
1650
  };
@@ -1654,7 +1654,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1654
1654
  };
1655
1655
  } & {
1656
1656
  _: {
1657
- fieldName: "startedAt";
1657
+ fieldName: "updatedAt";
1658
1658
  };
1659
1659
  };
1660
1660
  completedAt: ConvexNumberBuilderInitial<""> & {
@@ -1769,19 +1769,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1769
1769
  fieldName: "cursor";
1770
1770
  };
1771
1771
  };
1772
- updatedAt: ConvexNumberBuilderInitial<""> & {
1773
- _: {
1774
- notNull: true;
1775
- };
1776
- } & {
1777
- _: {
1778
- tableName: "migration_state";
1779
- };
1780
- } & {
1781
- _: {
1782
- fieldName: "updatedAt";
1783
- };
1784
- };
1785
1772
  migrationId: ConvexTextBuilderInitial<""> & {
1786
1773
  _: {
1787
1774
  notNull: true;
@@ -1852,6 +1839,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1852
1839
  fieldName: "startedAt";
1853
1840
  };
1854
1841
  };
1842
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1843
+ _: {
1844
+ notNull: true;
1845
+ };
1846
+ } & {
1847
+ _: {
1848
+ tableName: "migration_state";
1849
+ };
1850
+ } & {
1851
+ _: {
1852
+ fieldName: "updatedAt";
1853
+ };
1854
+ };
1855
1855
  completedAt: ConvexNumberBuilderInitial<""> & {
1856
1856
  _: {
1857
1857
  tableName: "migration_state";
@@ -1918,7 +1918,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1918
1918
  fieldName: "direction";
1919
1919
  };
1920
1920
  };
1921
- updatedAt: ConvexNumberBuilderInitial<""> & {
1921
+ runId: ConvexTextBuilderInitial<""> & {
1922
1922
  _: {
1923
1923
  notNull: true;
1924
1924
  };
@@ -1928,10 +1928,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1928
1928
  };
1929
1929
  } & {
1930
1930
  _: {
1931
- fieldName: "updatedAt";
1931
+ fieldName: "runId";
1932
1932
  };
1933
1933
  };
1934
- runId: ConvexTextBuilderInitial<""> & {
1934
+ startedAt: ConvexNumberBuilderInitial<""> & {
1935
1935
  _: {
1936
1936
  notNull: true;
1937
1937
  };
@@ -1941,10 +1941,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1941
1941
  };
1942
1942
  } & {
1943
1943
  _: {
1944
- fieldName: "runId";
1944
+ fieldName: "startedAt";
1945
1945
  };
1946
1946
  };
1947
- startedAt: ConvexNumberBuilderInitial<""> & {
1947
+ updatedAt: ConvexNumberBuilderInitial<""> & {
1948
1948
  _: {
1949
1949
  notNull: true;
1950
1950
  };
@@ -1954,7 +1954,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
1954
1954
  };
1955
1955
  } & {
1956
1956
  _: {
1957
- fieldName: "startedAt";
1957
+ fieldName: "updatedAt";
1958
1958
  };
1959
1959
  };
1960
1960
  completedAt: ConvexNumberBuilderInitial<""> & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kitcn",
3
- "version": "0.33.2",
3
+ "version": "0.33.4",
4
4
  "description": "kitcn - React Query integration and CLI tools for Convex",
5
5
  "keywords": [
6
6
  "convex",