kitcn 0.17.4 → 0.17.5
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/dist/aggregate/index.d.ts +1 -1
- package/dist/auth/client/index.d.ts +1 -1
- package/dist/auth/client/index.js +1 -1
- package/dist/auth/generated/index.d.ts +1 -1
- package/dist/auth/index.d.ts +12 -12
- package/dist/{auth-store-GDNKweSK.d.ts → auth-store-47WTg13B.d.ts} +4 -3
- package/dist/{auth-store-BnGZxmnY.js → auth-store-BHk8eMnX.js} +37 -13
- package/dist/{generated-contract-disabled-LOAfma7_.d.ts → generated-contract-disabled-CHR4NLoa.d.ts} +29 -29
- package/dist/orm/index.d.ts +1 -1
- package/dist/react/index.d.ts +9 -8
- package/dist/react/index.js +138 -58
- package/dist/{where-clause-compiler-BnVpjKn6.d.ts → where-clause-compiler-DVO0oBe9.d.ts} +4 -4
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial, dn as ConvexTableWithColumns, tr as ConvexTextBuilderInitial } from "../where-clause-compiler-
|
|
1
|
+
import { C as ConvexNumberBuilderInitial, E as ConvexIdBuilderInitial, N as ConvexCustomBuilderInitial, dn as ConvexTableWithColumns, tr as ConvexTextBuilderInitial } from "../where-clause-compiler-DVO0oBe9.js";
|
|
2
2
|
import * as convex_values0 from "convex/values";
|
|
3
3
|
import { GenericId, Infer, Value } from "convex/values";
|
|
4
4
|
import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { r as AuthStore } from "../../auth-store-
|
|
2
|
+
import { r as AuthStore } from "../../auth-store-47WTg13B.js";
|
|
3
3
|
import { ConvexReactClient } from "convex/react";
|
|
4
4
|
import { ReactNode } from "react";
|
|
5
5
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { A as
|
|
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-BHk8eMnX.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 { S as defineAuth, _ as GenericAuthBeforeResult, b as GenericAuthTriggerHandlers, g as BetterAuthOptionsWithoutDatabase, i as getGeneratedAuthDisabledReason, n as GeneratedAuthDisabledReasonKind, r as createDisabledAuthRuntime, t as AuthRuntime, v as GenericAuthDefinition, x as GenericAuthTriggers, y as GenericAuthTriggerChange } from "../../generated-contract-disabled-
|
|
1
|
+
import { S as defineAuth, _ as GenericAuthBeforeResult, b as GenericAuthTriggerHandlers, g as BetterAuthOptionsWithoutDatabase, i as getGeneratedAuthDisabledReason, n as GeneratedAuthDisabledReasonKind, r as createDisabledAuthRuntime, t as AuthRuntime, v as GenericAuthDefinition, x as GenericAuthTriggers, y as GenericAuthTriggerChange } from "../../generated-contract-disabled-CHR4NLoa.js";
|
|
2
2
|
export { type AuthRuntime, BetterAuthOptionsWithoutDatabase, type GeneratedAuthDisabledReasonKind, GenericAuthBeforeResult, GenericAuthDefinition, GenericAuthTriggerChange, GenericAuthTriggerHandlers, GenericAuthTriggers, createDisabledAuthRuntime, defineAuth, getGeneratedAuthDisabledReason };
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { a as QueryCtxWithPreferredOrmQueryTable, n as LookupByIdResultByCtx, t as DocByCtx } from "../query-context-CNo9ffvI.js";
|
|
2
2
|
import { t as GetAuth } from "../types-BCl8gfGy.js";
|
|
3
3
|
import { t as GenericCtx } from "../context-utils-BBUtBqjN.js";
|
|
4
|
-
import { S as defineAuth, _ as GenericAuthBeforeResult, a as AuthFunctions, b as GenericAuthTriggerHandlers, c as createApi, d as deleteOneHandler, f as findManyHandler, g as BetterAuthOptionsWithoutDatabase, h as updateOneHandler, i as getGeneratedAuthDisabledReason, l as createHandler, m as updateManyHandler, n as GeneratedAuthDisabledReasonKind, o as Triggers, p as findOneHandler, r as createDisabledAuthRuntime, s as createClient, t as AuthRuntime, u as deleteManyHandler, v as GenericAuthDefinition, x as GenericAuthTriggers, y as GenericAuthTriggerChange } from "../generated-contract-disabled-
|
|
4
|
+
import { S as defineAuth, _ as GenericAuthBeforeResult, a as AuthFunctions, b as GenericAuthTriggerHandlers, c as createApi, d as deleteOneHandler, f as findManyHandler, g as BetterAuthOptionsWithoutDatabase, h as updateOneHandler, i as getGeneratedAuthDisabledReason, l as createHandler, m as updateManyHandler, n as GeneratedAuthDisabledReasonKind, o as Triggers, p as findOneHandler, r as createDisabledAuthRuntime, s as createClient, t as AuthRuntime, u as deleteManyHandler, v as GenericAuthDefinition, x as GenericAuthTriggers, y as GenericAuthTriggerChange } from "../generated-contract-disabled-CHR4NLoa.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";
|
|
@@ -107,27 +107,27 @@ type AdapterPaginationOptions = PaginationOptions & {
|
|
|
107
107
|
};
|
|
108
108
|
declare const adapterWhereValidator: convex_values0.VObject<{
|
|
109
109
|
mode?: "sensitive" | "insensitive" | undefined;
|
|
110
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
110
111
|
connector?: "AND" | "OR" | undefined;
|
|
111
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
112
112
|
value: string | number | boolean | string[] | number[] | null;
|
|
113
113
|
field: string;
|
|
114
114
|
}, {
|
|
115
115
|
connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
|
|
116
116
|
field: convex_values0.VString<string, "required">;
|
|
117
117
|
mode: convex_values0.VUnion<"sensitive" | "insensitive" | undefined, [convex_values0.VLiteral<"sensitive", "required">, convex_values0.VLiteral<"insensitive", "required">], "optional", never>;
|
|
118
|
-
operator: convex_values0.VUnion<"
|
|
118
|
+
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>;
|
|
119
119
|
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>;
|
|
120
|
-
}, "required", "mode" | "value" | "
|
|
120
|
+
}, "required", "mode" | "value" | "operator" | "field" | "connector">;
|
|
121
121
|
declare const adapterArgsValidator: convex_values0.VObject<{
|
|
122
|
-
|
|
122
|
+
limit?: number | undefined;
|
|
123
123
|
where?: {
|
|
124
124
|
mode?: "sensitive" | "insensitive" | undefined;
|
|
125
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
125
126
|
connector?: "AND" | "OR" | undefined;
|
|
126
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
127
127
|
value: string | number | boolean | string[] | number[] | null;
|
|
128
128
|
field: string;
|
|
129
129
|
}[] | undefined;
|
|
130
|
-
|
|
130
|
+
select?: string[] | undefined;
|
|
131
131
|
offset?: number | undefined;
|
|
132
132
|
sortBy?: {
|
|
133
133
|
field: string;
|
|
@@ -148,24 +148,24 @@ declare const adapterArgsValidator: convex_values0.VObject<{
|
|
|
148
148
|
}, "optional", "field" | "direction">;
|
|
149
149
|
where: convex_values0.VArray<{
|
|
150
150
|
mode?: "sensitive" | "insensitive" | undefined;
|
|
151
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
151
152
|
connector?: "AND" | "OR" | undefined;
|
|
152
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
153
153
|
value: string | number | boolean | string[] | number[] | null;
|
|
154
154
|
field: string;
|
|
155
155
|
}[] | undefined, convex_values0.VObject<{
|
|
156
156
|
mode?: "sensitive" | "insensitive" | undefined;
|
|
157
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
157
158
|
connector?: "AND" | "OR" | undefined;
|
|
158
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
159
159
|
value: string | number | boolean | string[] | number[] | null;
|
|
160
160
|
field: string;
|
|
161
161
|
}, {
|
|
162
162
|
connector: convex_values0.VUnion<"AND" | "OR" | undefined, [convex_values0.VLiteral<"AND", "required">, convex_values0.VLiteral<"OR", "required">], "optional", never>;
|
|
163
163
|
field: convex_values0.VString<string, "required">;
|
|
164
164
|
mode: convex_values0.VUnion<"sensitive" | "insensitive" | undefined, [convex_values0.VLiteral<"sensitive", "required">, convex_values0.VLiteral<"insensitive", "required">], "optional", never>;
|
|
165
|
-
operator: convex_values0.VUnion<"
|
|
165
|
+
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>;
|
|
166
166
|
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>;
|
|
167
|
-
}, "required", "mode" | "value" | "
|
|
168
|
-
}, "required", "
|
|
167
|
+
}, "required", "mode" | "value" | "operator" | "field" | "connector">, "optional">;
|
|
168
|
+
}, "required", "limit" | "where" | "model" | "select" | "offset" | "sortBy" | "sortBy.field" | "sortBy.direction">;
|
|
169
169
|
declare const hasUniqueFields: (betterAuthSchema: BetterAuthDBSchema, model: string, input: Record<string, any>) => boolean;
|
|
170
170
|
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>;
|
|
171
171
|
declare const selectFields: <T extends TableNamesInDataModel<GenericDataModel>, D extends DocumentByName<GenericDataModel, T>>(doc: D | null, select?: string[]) => D | null;
|
|
@@ -5,6 +5,9 @@ import * as jotai_x0 from "jotai-x";
|
|
|
5
5
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
6
6
|
import * as jotai_vanilla0 from "jotai/vanilla";
|
|
7
7
|
|
|
8
|
+
//#region src/internal/jwt.d.ts
|
|
9
|
+
declare const decodeJwtExp: (token: string) => number | null;
|
|
10
|
+
//#endregion
|
|
8
11
|
//#region src/react/auth-store.d.ts
|
|
9
12
|
type FetchAccessTokenFn = (args: {
|
|
10
13
|
forceRefreshToken: boolean;
|
|
@@ -49,8 +52,6 @@ type AuthStoreState = {
|
|
|
49
52
|
};
|
|
50
53
|
declare const AUTH_SESSION_SYNC_GRACE_MS = 10000;
|
|
51
54
|
declare const isSessionSyncGraceActive: (sessionSyncGraceUntil: number | null) => boolean;
|
|
52
|
-
/** Decode JWT expiration (ms timestamp) from token */
|
|
53
|
-
declare function decodeJwtExp(token: string): number | null;
|
|
54
55
|
declare const AuthProvider: react.FC<jotai_x0.ProviderProps<{
|
|
55
56
|
onMutationUnauthorized: () => void;
|
|
56
57
|
onQueryUnauthorized: (info: {
|
|
@@ -171,4 +172,4 @@ declare function Unauthenticated({
|
|
|
171
172
|
children: React.ReactNode;
|
|
172
173
|
}): react.ReactNode;
|
|
173
174
|
//#endregion
|
|
174
|
-
export {
|
|
175
|
+
export { decodeJwtExp as A, useAuthValue as C, useIsAuth as D, useFetchAccessToken as E, useMaybeAuth as O, useAuthStore as S, useConvexAuthRecovery as T, Unauthenticated as _, Authenticated as a, useAuthGuard as b, ConvexAuthRecoveryError as c, ConvexAuthRecoveryStatus as d, ConvexProviderWithAuth$1 as f, MaybeUnauthenticated as g, MaybeAuthenticated as h, AuthStoreState as i, useSafeConvexAuth as k, ConvexAuthRecoveryErrorCode as l, FetchAccessTokenFn as m, AuthProvider as n, ConvexAuthBridge as o, FetchAccessTokenContext as p, AuthStore as r, ConvexAuthRecovery as s, AUTH_SESSION_SYNC_GRACE_MS as t, ConvexAuthRecoveryOptions as u, isSessionSyncGraceActive as v, useConvexAuthBridge as w, useAuthState as x, useAuth as y };
|
|
@@ -84,6 +84,42 @@ const clearAuthSessionFallback = () => {
|
|
|
84
84
|
writeAuthSessionFallbackData(null);
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/internal/jwt.ts
|
|
89
|
+
const VOLATILE_JWT_CLAIMS = new Set([
|
|
90
|
+
"exp",
|
|
91
|
+
"iat",
|
|
92
|
+
"jti",
|
|
93
|
+
"nbf"
|
|
94
|
+
]);
|
|
95
|
+
const decodeJwtPayload = (token) => {
|
|
96
|
+
try {
|
|
97
|
+
const segment = token.split(".")[1];
|
|
98
|
+
if (!segment) return null;
|
|
99
|
+
const binary = atob(segment.replaceAll("-", "+").replaceAll("_", "/"));
|
|
100
|
+
const payload = JSON.parse(new TextDecoder().decode(Uint8Array.from(binary, (char) => char.charCodeAt(0))));
|
|
101
|
+
return typeof payload === "object" && payload !== null ? payload : null;
|
|
102
|
+
} catch {
|
|
103
|
+
return null;
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
const stableStringify = (value) => {
|
|
107
|
+
if (value === null || typeof value !== "object") return JSON.stringify(value);
|
|
108
|
+
if (Array.isArray(value)) return `[${value.map(stableStringify).join(",")}]`;
|
|
109
|
+
return `{${Object.entries(value).filter(([, claim]) => claim !== void 0).sort(([a], [b]) => a < b ? -1 : 1).map(([key, claim]) => `${JSON.stringify(key)}:${stableStringify(claim)}`).join(",")}}`;
|
|
110
|
+
};
|
|
111
|
+
const decodeJwtExp = (token) => {
|
|
112
|
+
const payload = decodeJwtPayload(token);
|
|
113
|
+
return payload?.exp ? Number(payload.exp) * 1e3 : null;
|
|
114
|
+
};
|
|
115
|
+
const decodeJwtIdentity = (token) => {
|
|
116
|
+
const payload = decodeJwtPayload(token);
|
|
117
|
+
if (!payload) return null;
|
|
118
|
+
const claims = {};
|
|
119
|
+
for (const [key, claim] of Object.entries(payload)) if (!VOLATILE_JWT_CLAIMS.has(key)) claims[key] = claim;
|
|
120
|
+
return stableStringify(claims);
|
|
121
|
+
};
|
|
122
|
+
|
|
87
123
|
//#endregion
|
|
88
124
|
//#region src/react/auth-store.tsx
|
|
89
125
|
/**
|
|
@@ -167,18 +203,6 @@ function ConvexAuthBinding({ bindingVersion, children, client, onAuthSnapshot, o
|
|
|
167
203
|
}
|
|
168
204
|
const AUTH_SESSION_SYNC_GRACE_MS = 1e4;
|
|
169
205
|
const isSessionSyncGraceActive = (sessionSyncGraceUntil) => typeof sessionSyncGraceUntil === "number" && sessionSyncGraceUntil > Date.now();
|
|
170
|
-
/** Decode JWT expiration (ms timestamp) from token */
|
|
171
|
-
function decodeJwtExp(token) {
|
|
172
|
-
try {
|
|
173
|
-
const segment = token.split(".")[1];
|
|
174
|
-
if (!segment) return null;
|
|
175
|
-
const binary = atob(segment.replaceAll("-", "+").replaceAll("_", "/"));
|
|
176
|
-
const payload = JSON.parse(new TextDecoder().decode(Uint8Array.from(binary, (char) => char.charCodeAt(0))));
|
|
177
|
-
return payload.exp ? payload.exp * 1e3 : null;
|
|
178
|
-
} catch {
|
|
179
|
-
return null;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
206
|
const { AuthProvider, useAuthStore, useAuthState, useAuthValue } = createAtomStore({
|
|
183
207
|
onMutationUnauthorized: () => {
|
|
184
208
|
throw new CRPCClientError({
|
|
@@ -430,4 +454,4 @@ function Unauthenticated({ children }) {
|
|
|
430
454
|
}
|
|
431
455
|
|
|
432
456
|
//#endregion
|
|
433
|
-
export {
|
|
457
|
+
export { CRPCClientError as A, decodeJwtExp as C, readAuthSessionFallbackToken as D, readAuthSessionFallbackData as E, isCRPCClientError as M, writeAuthSessionFallbackData as O, useSafeConvexAuth as S, clearAuthSessionFallback as T, useConvexAuthBridge as _, ConvexAuthRecoveryError as a, useIsAuth as b, MaybeAuthenticated as c, isSessionSyncGraceActive as d, useAuth as f, useAuthValue as g, useAuthStore as h, ConvexAuthBridge as i, defaultIsUnauthorized as j, writeAuthSessionFallbackToken as k, MaybeUnauthenticated as l, useAuthState as m, AuthProvider as n, ConvexProviderWithAuth$1 as o, useAuthGuard as p, Authenticated as r, FetchAccessTokenContext as s, AUTH_SESSION_SYNC_GRACE_MS as t, Unauthenticated as u, useConvexAuthRecovery as v, decodeJwtIdentity as w, useMaybeAuth as x, useFetchAccessToken as y };
|
package/dist/{generated-contract-disabled-LOAfma7_.d.ts → generated-contract-disabled-CHR4NLoa.d.ts}
RENAMED
|
@@ -173,10 +173,18 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
173
173
|
};
|
|
174
174
|
}, Promise<any>>;
|
|
175
175
|
deleteMany: convex_server0.RegisteredMutation<"internal", {
|
|
176
|
+
paginationOpts: {
|
|
177
|
+
id?: number;
|
|
178
|
+
endCursor?: string | null;
|
|
179
|
+
maximumRowsRead?: number;
|
|
180
|
+
maximumBytesRead?: number;
|
|
181
|
+
numItems: number;
|
|
182
|
+
cursor: string | null;
|
|
183
|
+
};
|
|
176
184
|
input: {
|
|
177
185
|
where?: {
|
|
186
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
178
187
|
connector?: "AND" | "OR" | undefined;
|
|
179
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
180
188
|
value: string | number | boolean | string[] | number[] | null;
|
|
181
189
|
field: string;
|
|
182
190
|
}[] | undefined;
|
|
@@ -185,14 +193,6 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
185
193
|
where?: any[] | undefined;
|
|
186
194
|
model: string;
|
|
187
195
|
};
|
|
188
|
-
paginationOpts: {
|
|
189
|
-
id?: number;
|
|
190
|
-
endCursor?: string | null;
|
|
191
|
-
maximumRowsRead?: number;
|
|
192
|
-
maximumBytesRead?: number;
|
|
193
|
-
numItems: number;
|
|
194
|
-
cursor: string | null;
|
|
195
|
-
};
|
|
196
196
|
}, Promise<{
|
|
197
197
|
count: number;
|
|
198
198
|
ids: any[];
|
|
@@ -204,8 +204,8 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
204
204
|
deleteOne: convex_server0.RegisteredMutation<"internal", {
|
|
205
205
|
input: {
|
|
206
206
|
where?: {
|
|
207
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
207
208
|
connector?: "AND" | "OR" | undefined;
|
|
208
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
209
209
|
value: string | number | boolean | string[] | number[] | null;
|
|
210
210
|
field: string;
|
|
211
211
|
}[] | undefined;
|
|
@@ -217,20 +217,19 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
217
217
|
}, Promise<Record<string, unknown> | undefined>>;
|
|
218
218
|
findMany: convex_server0.RegisteredQuery<"internal", {
|
|
219
219
|
join?: any;
|
|
220
|
+
limit?: number | undefined;
|
|
220
221
|
where?: {
|
|
221
222
|
mode?: "sensitive" | "insensitive" | undefined;
|
|
223
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
222
224
|
connector?: "AND" | "OR" | undefined;
|
|
223
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
224
225
|
value: string | number | boolean | string[] | number[] | null;
|
|
225
226
|
field: string;
|
|
226
227
|
}[] | undefined;
|
|
227
|
-
limit?: number | undefined;
|
|
228
228
|
offset?: number | undefined;
|
|
229
229
|
sortBy?: {
|
|
230
230
|
field: string;
|
|
231
231
|
direction: "asc" | "desc";
|
|
232
232
|
} | undefined;
|
|
233
|
-
model: string;
|
|
234
233
|
paginationOpts: {
|
|
235
234
|
id?: number;
|
|
236
235
|
endCursor?: string | null;
|
|
@@ -239,47 +238,48 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
239
238
|
numItems: number;
|
|
240
239
|
cursor: string | null;
|
|
241
240
|
};
|
|
241
|
+
model: string;
|
|
242
242
|
}, Promise<convex_server0.PaginationResult<convex_server0.GenericDocument>>>;
|
|
243
243
|
findOne: convex_server0.RegisteredQuery<"internal", {
|
|
244
244
|
join?: any;
|
|
245
|
-
select?: string[] | undefined;
|
|
246
245
|
where?: {
|
|
247
246
|
mode?: "sensitive" | "insensitive" | undefined;
|
|
247
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
248
248
|
connector?: "AND" | "OR" | undefined;
|
|
249
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
250
249
|
value: string | number | boolean | string[] | number[] | null;
|
|
251
250
|
field: string;
|
|
252
251
|
}[] | undefined;
|
|
252
|
+
select?: string[] | undefined;
|
|
253
253
|
model: string;
|
|
254
254
|
}, Promise<convex_server0.GenericDocument | null>>;
|
|
255
255
|
getLatestJwks: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
|
|
256
256
|
rotateKeys: convex_server0.RegisteredAction<"internal", {}, Promise<unknown>>;
|
|
257
257
|
updateMany: convex_server0.RegisteredMutation<"internal", {
|
|
258
|
+
paginationOpts: {
|
|
259
|
+
id?: number;
|
|
260
|
+
endCursor?: string | null;
|
|
261
|
+
maximumRowsRead?: number;
|
|
262
|
+
maximumBytesRead?: number;
|
|
263
|
+
numItems: number;
|
|
264
|
+
cursor: string | null;
|
|
265
|
+
};
|
|
258
266
|
input: {
|
|
259
267
|
where?: {
|
|
268
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
260
269
|
connector?: "AND" | "OR" | undefined;
|
|
261
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
262
270
|
value: string | number | boolean | string[] | number[] | null;
|
|
263
271
|
field: string;
|
|
264
272
|
}[] | undefined;
|
|
265
|
-
model: string;
|
|
266
273
|
update: {
|
|
267
274
|
[x: string]: unknown;
|
|
268
275
|
[x: number]: unknown;
|
|
269
276
|
[x: symbol]: unknown;
|
|
270
277
|
};
|
|
278
|
+
model: string;
|
|
271
279
|
} | {
|
|
272
280
|
where?: any[] | undefined;
|
|
273
|
-
model: string;
|
|
274
281
|
update: any;
|
|
275
|
-
|
|
276
|
-
paginationOpts: {
|
|
277
|
-
id?: number;
|
|
278
|
-
endCursor?: string | null;
|
|
279
|
-
maximumRowsRead?: number;
|
|
280
|
-
maximumBytesRead?: number;
|
|
281
|
-
numItems: number;
|
|
282
|
-
cursor: string | null;
|
|
282
|
+
model: string;
|
|
283
283
|
};
|
|
284
284
|
}, Promise<{
|
|
285
285
|
count: number;
|
|
@@ -292,21 +292,21 @@ declare const createApi: <Schema extends SchemaDefinition<any, any>, DataModel e
|
|
|
292
292
|
updateOne: convex_server0.RegisteredMutation<"internal", {
|
|
293
293
|
input: {
|
|
294
294
|
where?: {
|
|
295
|
+
operator?: "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in" | "not_in" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
295
296
|
connector?: "AND" | "OR" | undefined;
|
|
296
|
-
operator?: "lt" | "lte" | "gt" | "gte" | "eq" | "in" | "not_in" | "ne" | "contains" | "starts_with" | "ends_with" | undefined;
|
|
297
297
|
value: string | number | boolean | string[] | number[] | null;
|
|
298
298
|
field: string;
|
|
299
299
|
}[] | undefined;
|
|
300
|
-
model: string;
|
|
301
300
|
update: {
|
|
302
301
|
[x: string]: unknown;
|
|
303
302
|
[x: number]: unknown;
|
|
304
303
|
[x: symbol]: unknown;
|
|
305
304
|
};
|
|
305
|
+
model: string;
|
|
306
306
|
} | {
|
|
307
307
|
where?: any[] | undefined;
|
|
308
|
-
model: string;
|
|
309
308
|
update: any;
|
|
309
|
+
model: string;
|
|
310
310
|
};
|
|
311
311
|
}, Promise<any>>;
|
|
312
312
|
};
|
package/dist/orm/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as GenericOrmCtx$1, $n as unique, $r as endsWith, $t as ManyConfig, A as ConvexDateMode, An as ConvexRankIndexBuilder, Ar as ReturningResult, At as MigrationManifestEntry, B as ConvexBytesBuilderInitial, Bn as rankIndex, Br as OrmSchemaRelations, Bt as defineMigration, C as ConvexNumberBuilderInitial, Ci as ColumnBuilderWithTableName, Cn as RlsRole, Cr as MutationReturning, Ct as MigrationStatusArgs, D as id, Di as IsPrimaryKey, Dn as ConvexAggregateIndexBuilderOn, Dr as PaginatedResult, Dt as MigrationDoc, E as ConvexIdBuilderInitial, Ei as HasDefault, En as ConvexAggregateIndexBuilder, Er as OrderDirection, Et as MigrationDirection, F as custom, Fn as ConvexVectorIndexBuilder, Fr as unsetToken, Ft as MigrationStateMap, G as ConvexBigIntBuilder, Gn as ConvexCheckConfig, Gr as ExpressionVisitor, Gt as OrmReader$1, H as ConvexBooleanBuilder, Hn as uniqueIndex, Hr as TableName, Ht as detectMigrationDrift, I as json, In as ConvexVectorIndexBuilderOn, Ir as Brand, It as MigrationStep, J as CountBackfillChunkArgs, Jn as ConvexUniqueConstraintBuilder, Jr as LogicalExpression, Jt as RlsMode, K as ConvexBigIntBuilderInitial, Kn as ConvexForeignKeyBuilder, Kr as FieldReference, Kt as OrmWriter$1, L as objectOf, Ln as ConvexVectorIndexConfig, Lr as Columns, Lt as MigrationTableName, M as ConvexCustomBuilder, Mn as ConvexSearchIndexBuilder, Mr as UpdateSet, Mt as MigrationPlan, N as ConvexCustomBuilderInitial, Nn as ConvexSearchIndexBuilderOn, Nr as VectorQueryConfig, Nt as MigrationRunStatus, O as ConvexDateBuilder, Oi as IsUnique, On as ConvexIndexBuilder, Or as PredicateWhereIndexConfig, Ot as MigrationDocContext, P as arrayOf, Pn as ConvexSearchIndexConfig, Pr as VectorSearchProvider, Pt as MigrationSet, Q as GenericOrm$1, Qn as foreignKey, Qr as contains, Qt as ExtractTablesWithRelations, R as unionOf, Rn as aggregateIndex, Rr as OrmSchemaExtensionTables, Rt as MigrationWriteMode, S as ConvexNumberBuilder, Si as ColumnBuilderTypeConfig, Sn as rlsPolicy, Sr as MutationResult, St as MigrationRunChunkArgs, T as ConvexIdBuilder, Ti as DrizzleEntity, Tn as rlsRole, Tr as OrderByClause, Tt as MigrationDefinition, U as ConvexBooleanBuilderInitial, Un as vectorIndex, Ur as SystemFields, Ut as DatabaseWithMutations, V as bytes, Vn as searchIndex, Vr as OrmSchemaTriggers, Vt as defineMigrationSet, W as boolean, Wn as ConvexCheckBuilder, Wr as BinaryExpression, Wt as DatabaseWithQuery, X as CountBackfillStatusArgs, Xn as ConvexUniqueConstraintConfig, Xr as and, Xt as extractRelationsConfig, Y as CountBackfillKickoffArgs, Yn as ConvexUniqueConstraintBuilderOn, Yr as UnaryExpression, Yt as EdgeMetadata, Z as CreateOrmOptions, Zn as check, Zr as between, Zt as ExtractTablesFromSchema, _ as ConvexTimestampMode, _i as startsWith, _n as deletion, _r as MutationExecuteConfig, _t as OrmTriggerContext, a as requireSchemaRelations, ai as inArray, an as TablesRelationalConfig, ar as AggregateResult, at as OrmWriterCtx, b as ConvexTextEnumBuilderInitial, bi as ColumnBuilderBaseConfig, bn as RlsPolicyConfig, br as MutationPaginateConfig, bt as MigrationCancelArgs, c as TableConfigResult, ci as isNull, cn as ConvexDeletionBuilder, cr as CountConfig, ct as ScheduledMutationBatchArgs, d as OrmNotFoundError, di as lte, dn as ConvexTableWithColumns, dr as FilterOperators, dt as scheduledDeleteFactory, ei as eq, en as OneConfig, er as ConvexTextBuilder, et as OrmApiResult, f as ConvexVectorBuilder, fi as ne, fn as DiscriminatorBuilderConfig, fr as GetColumnData, ft as SchemaExtension, g as ConvexTimestampBuilderInitial, gi as or, gn as convexTable, gr as InsertValue, gt as OrmTriggerChange, h as ConvexTimestampBuilder, hi as notInArray, hn as TableConfig, hr as InferSelectModel, ht as OrmTableTriggers, i as getSchemaTriggers, ii as ilike, in as TableRelationalConfig, ir as AggregateFieldValue, it as OrmReaderCtx, j as date, jn as ConvexRankIndexBuilderOn, jr as ReturningSelection, jt as MigrationMigrateOne, k as ConvexDateBuilderInitial, ki as NotNull, kn as ConvexIndexBuilderOn, kr as ReturningAll, kt as MigrationDriftIssue, l as getTableColumns, li as like, ln as ConvexDeletionConfig, lr as CountResult, lt as scheduledMutationBatchFactory, m as vector, mi as notBetween, mn as OrmLifecycleOperation, mr as InferModelFromColumns, mt as OrmBeforeResult, n as defineSchema, ni as gt, nn as RelationsBuilderColumnBase, nr as text, nt as OrmClientWithApi$1, o as asc, oi as isFieldReference, on as defineRelations, or as BuildQueryResult, ot as ResolveOrmSchema, p as ConvexVectorBuilderInitial, pi as not, pn as OrmLifecycleChange, pr as InferInsertModel, pt as defineSchemaExtension, q as bigint, qn as ConvexForeignKeyConfig, qr as FilterExpression, qt as RlsContext, r as getSchemaRelations, ri as gte, rn as RelationsBuilderColumnConfig, rr as AggregateConfig, rt as OrmFunctions, s as desc, si as isNotNull, sn as defineRelationsPart, sr as BuildRelationResult, st as createOrm, t as WhereClauseResult, ti as fieldRef, tn as RelationsBuilder, tr as ConvexTextBuilderInitial, tt as OrmClientBase$1, u as getTableConfig, ui as lt, un as ConvexTable, ur as DBQueryConfig, ut as ScheduledDeleteArgs, v as timestamp, vi as AnyColumn, vn as discriminator, vr as MutationExecuteResult, vt as OrmTriggers, w as integer, wi as ColumnDataType, wn as RlsRoleConfig, wr as MutationRunMode, wt as MigrationAppliedState, x as textEnum, xi as ColumnBuilderRuntimeConfig, xn as RlsPolicyToOption, xr as MutationPaginatedResult, xt as MigrationRunArgs, y as ConvexTextEnumBuilder, yi as ColumnBuilder, yn as RlsPolicy, yr as MutationExecutionMode, yt as defineTriggers, z as ConvexBytesBuilder, zn as index, zr as OrmSchemaExtensions, zt as buildMigrationPlan } from "../where-clause-compiler-
|
|
1
|
+
import { $ as GenericOrmCtx$1, $n as unique, $r as endsWith, $t as ManyConfig, A as ConvexDateMode, An as ConvexRankIndexBuilder, Ar as ReturningResult, At as MigrationManifestEntry, B as ConvexBytesBuilderInitial, Bn as rankIndex, Br as OrmSchemaRelations, Bt as defineMigration, C as ConvexNumberBuilderInitial, Ci as ColumnBuilderWithTableName, Cn as RlsRole, Cr as MutationReturning, Ct as MigrationStatusArgs, D as id, Di as IsPrimaryKey, Dn as ConvexAggregateIndexBuilderOn, Dr as PaginatedResult, Dt as MigrationDoc, E as ConvexIdBuilderInitial, Ei as HasDefault, En as ConvexAggregateIndexBuilder, Er as OrderDirection, Et as MigrationDirection, F as custom, Fn as ConvexVectorIndexBuilder, Fr as unsetToken, Ft as MigrationStateMap, G as ConvexBigIntBuilder, Gn as ConvexCheckConfig, Gr as ExpressionVisitor, Gt as OrmReader$1, H as ConvexBooleanBuilder, Hn as uniqueIndex, Hr as TableName, Ht as detectMigrationDrift, I as json, In as ConvexVectorIndexBuilderOn, Ir as Brand, It as MigrationStep, J as CountBackfillChunkArgs, Jn as ConvexUniqueConstraintBuilder, Jr as LogicalExpression, Jt as RlsMode, K as ConvexBigIntBuilderInitial, Kn as ConvexForeignKeyBuilder, Kr as FieldReference, Kt as OrmWriter$1, L as objectOf, Ln as ConvexVectorIndexConfig, Lr as Columns, Lt as MigrationTableName, M as ConvexCustomBuilder, Mn as ConvexSearchIndexBuilder, Mr as UpdateSet, Mt as MigrationPlan, N as ConvexCustomBuilderInitial, Nn as ConvexSearchIndexBuilderOn, Nr as VectorQueryConfig, Nt as MigrationRunStatus, O as ConvexDateBuilder, Oi as IsUnique, On as ConvexIndexBuilder, Or as PredicateWhereIndexConfig, Ot as MigrationDocContext, P as arrayOf, Pn as ConvexSearchIndexConfig, Pr as VectorSearchProvider, Pt as MigrationSet, Q as GenericOrm$1, Qn as foreignKey, Qr as contains, Qt as ExtractTablesWithRelations, R as unionOf, Rn as aggregateIndex, Rr as OrmSchemaExtensionTables, Rt as MigrationWriteMode, S as ConvexNumberBuilder, Si as ColumnBuilderTypeConfig, Sn as rlsPolicy, Sr as MutationResult, St as MigrationRunChunkArgs, T as ConvexIdBuilder, Ti as DrizzleEntity, Tn as rlsRole, Tr as OrderByClause, Tt as MigrationDefinition, U as ConvexBooleanBuilderInitial, Un as vectorIndex, Ur as SystemFields, Ut as DatabaseWithMutations, V as bytes, Vn as searchIndex, Vr as OrmSchemaTriggers, Vt as defineMigrationSet, W as boolean, Wn as ConvexCheckBuilder, Wr as BinaryExpression, Wt as DatabaseWithQuery, X as CountBackfillStatusArgs, Xn as ConvexUniqueConstraintConfig, Xr as and, Xt as extractRelationsConfig, Y as CountBackfillKickoffArgs, Yn as ConvexUniqueConstraintBuilderOn, Yr as UnaryExpression, Yt as EdgeMetadata, Z as CreateOrmOptions, Zn as check, Zr as between, Zt as ExtractTablesFromSchema, _ as ConvexTimestampMode, _i as startsWith, _n as deletion, _r as MutationExecuteConfig, _t as OrmTriggerContext, a as requireSchemaRelations, ai as inArray, an as TablesRelationalConfig, ar as AggregateResult, at as OrmWriterCtx, b as ConvexTextEnumBuilderInitial, bi as ColumnBuilderBaseConfig, bn as RlsPolicyConfig, br as MutationPaginateConfig, bt as MigrationCancelArgs, c as TableConfigResult, ci as isNull, cn as ConvexDeletionBuilder, cr as CountConfig, ct as ScheduledMutationBatchArgs, d as OrmNotFoundError, di as lte, dn as ConvexTableWithColumns, dr as FilterOperators, dt as scheduledDeleteFactory, ei as eq, en as OneConfig, er as ConvexTextBuilder, et as OrmApiResult, f as ConvexVectorBuilder, fi as ne, fn as DiscriminatorBuilderConfig, fr as GetColumnData, ft as SchemaExtension, g as ConvexTimestampBuilderInitial, gi as or, gn as convexTable, gr as InsertValue, gt as OrmTriggerChange, h as ConvexTimestampBuilder, hi as notInArray, hn as TableConfig, hr as InferSelectModel, ht as OrmTableTriggers, i as getSchemaTriggers, ii as ilike, in as TableRelationalConfig, ir as AggregateFieldValue, it as OrmReaderCtx, j as date, jn as ConvexRankIndexBuilderOn, jr as ReturningSelection, jt as MigrationMigrateOne, k as ConvexDateBuilderInitial, ki as NotNull, kn as ConvexIndexBuilderOn, kr as ReturningAll, kt as MigrationDriftIssue, l as getTableColumns, li as like, ln as ConvexDeletionConfig, lr as CountResult, lt as scheduledMutationBatchFactory, m as vector, mi as notBetween, mn as OrmLifecycleOperation, mr as InferModelFromColumns, mt as OrmBeforeResult, n as defineSchema, ni as gt, nn as RelationsBuilderColumnBase, nr as text, nt as OrmClientWithApi$1, o as asc, oi as isFieldReference, on as defineRelations, or as BuildQueryResult, ot as ResolveOrmSchema, p as ConvexVectorBuilderInitial, pi as not, pn as OrmLifecycleChange, pr as InferInsertModel, pt as defineSchemaExtension, q as bigint, qn as ConvexForeignKeyConfig, qr as FilterExpression, qt as RlsContext, r as getSchemaRelations, ri as gte, rn as RelationsBuilderColumnConfig, rr as AggregateConfig, rt as OrmFunctions, s as desc, si as isNotNull, sn as defineRelationsPart, sr as BuildRelationResult, st as createOrm, t as WhereClauseResult, ti as fieldRef, tn as RelationsBuilder, tr as ConvexTextBuilderInitial, tt as OrmClientBase$1, u as getTableConfig, ui as lt, un as ConvexTable, ur as DBQueryConfig, ut as ScheduledDeleteArgs, v as timestamp, vi as AnyColumn, vn as discriminator, vr as MutationExecuteResult, vt as OrmTriggers, w as integer, wi as ColumnDataType, wn as RlsRoleConfig, wr as MutationRunMode, wt as MigrationAppliedState, x as textEnum, xi as ColumnBuilderRuntimeConfig, xn as RlsPolicyToOption, xr as MutationPaginatedResult, xt as MigrationRunArgs, y as ConvexTextEnumBuilder, yi as ColumnBuilder, yn as RlsPolicy, yr as MutationExecutionMode, yt as defineTriggers, z as ConvexBytesBuilder, zn as index, zr as OrmSchemaExtensions, zt as buildMigrationPlan } from "../where-clause-compiler-DVO0oBe9.js";
|
|
2
2
|
import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-BhsByJeg.js";
|
|
3
3
|
import { a as QueryCtxWithPreferredOrmQueryTable, i as QueryCtxWithOrmQueryTable, n as LookupByIdResultByCtx, o as getByIdWithOrmQueryFallback, r as QueryCtxWithOptionalOrmQueryTable, t as DocByCtx } from "../query-context-CNo9ffvI.js";
|
|
4
4
|
import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchemaDefinition } from "convex/server";
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { A as
|
|
2
|
+
import { A as decodeJwtExp, C as useAuthValue, D as useIsAuth, E as useFetchAccessToken, O as useMaybeAuth, S as useAuthStore, T as useConvexAuthRecovery, _ as Unauthenticated, a as Authenticated, b as useAuthGuard, c as ConvexAuthRecoveryError, d as ConvexAuthRecoveryStatus, f as ConvexProviderWithAuth, g as MaybeUnauthenticated, h as MaybeAuthenticated, i as AuthStoreState, k as useSafeConvexAuth, l as ConvexAuthRecoveryErrorCode, m as FetchAccessTokenFn, n as AuthProvider, o as ConvexAuthBridge, p as FetchAccessTokenContext, r as AuthStore, s as ConvexAuthRecovery, t as AUTH_SESSION_SYNC_GRACE_MS, u as ConvexAuthRecoveryOptions, v as isSessionSyncGraceActive, w as useConvexAuthBridge, x as useAuthState, y as useAuth } from "../auth-store-47WTg13B.js";
|
|
3
3
|
import { ConvexProvider, ConvexReactClient, ConvexReactClient as ConvexReactClient$1, ConvexReactClientOptions, Watch, WatchQueryOptions, useConvex } from "convex/react";
|
|
4
4
|
import { ReactNode } from "react";
|
|
5
5
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
@@ -236,7 +236,6 @@ declare class ConvexQueryClient {
|
|
|
236
236
|
/** Unsubscribe a live Convex watch (if present) and remove it from the subscription map. */
|
|
237
237
|
private unsubscribeQueryByHash;
|
|
238
238
|
private isAuthBoundQuery;
|
|
239
|
-
private isQueryDisabled;
|
|
240
239
|
private subscribeQuery;
|
|
241
240
|
/** Update auth store (for HMR where jotai store may reset) */
|
|
242
241
|
updateAuthStore(authStore?: AuthStore): void;
|
|
@@ -986,6 +985,12 @@ declare function useInfiniteQuery<T extends FunctionReference<'query'>, TItem =
|
|
|
986
985
|
//#region src/react/use-query-options.d.ts
|
|
987
986
|
type ReservedQueryOptions = 'queryKey' | 'queryFn' | 'staleTime';
|
|
988
987
|
type ReservedMutationOptions = 'mutationFn';
|
|
988
|
+
type QueryOptionsResult<T extends FunctionReference<'query'>> = ConvexQueryOptions<T> & {
|
|
989
|
+
meta: ConvexQueryMeta;
|
|
990
|
+
};
|
|
991
|
+
type ActionQueryOptionsResult<T extends FunctionReference<'action'>> = ConvexActionOptions<T> & {
|
|
992
|
+
meta: ConvexQueryMeta;
|
|
993
|
+
};
|
|
989
994
|
/**
|
|
990
995
|
* Hook that returns query options for use with useQuery.
|
|
991
996
|
* Handles skipUnauth by setting enabled: false when unauthorized.
|
|
@@ -1010,9 +1015,7 @@ type ReservedMutationOptions = 'mutationFn';
|
|
|
1010
1015
|
* const { data } = useQuery(useConvexQueryOptions(api.user.get, { id }, { enabled: !!id, placeholderData: [] }));
|
|
1011
1016
|
* ```
|
|
1012
1017
|
*/
|
|
1013
|
-
declare function useConvexQueryOptions<T extends FunctionReference<'query'>>(funcRef: T, args: FunctionArgs<T> | SkipToken, options?: ConvexQueryHookOptions & DistributiveOmit<UseQueryOptions<FunctionReturnType<T>, DefaultError>, ReservedQueryOptions>):
|
|
1014
|
-
meta: ConvexQueryMeta;
|
|
1015
|
-
};
|
|
1018
|
+
declare function useConvexQueryOptions<T extends FunctionReference<'query'>>(funcRef: T, args: FunctionArgs<T> | SkipToken, options?: ConvexQueryHookOptions & DistributiveOmit<UseQueryOptions<FunctionReturnType<T>, DefaultError>, ReservedQueryOptions>): QueryOptionsResult<T>;
|
|
1016
1019
|
/**
|
|
1017
1020
|
* Hook that returns infinite query options for use with useInfiniteQuery.
|
|
1018
1021
|
* Handles auth type detection from meta and skipUnauth.
|
|
@@ -1060,9 +1063,7 @@ declare function useConvexInfiniteQueryOptions<T extends FunctionReference<'quer
|
|
|
1060
1063
|
*/
|
|
1061
1064
|
declare function useConvexActionQueryOptions<Action extends FunctionReference<'action'>>(action: Action, args: FunctionArgs<Action> | SkipToken, options?: {
|
|
1062
1065
|
skipUnauth?: boolean;
|
|
1063
|
-
} & DistributiveOmit<UseQueryOptions<FunctionReturnType<Action>, DefaultError>, ReservedQueryOptions>):
|
|
1064
|
-
meta: ConvexQueryMeta;
|
|
1065
|
-
};
|
|
1066
|
+
} & DistributiveOmit<UseQueryOptions<FunctionReturnType<Action>, DefaultError>, ReservedQueryOptions>): ActionQueryOptionsResult<Action>;
|
|
1066
1067
|
/**
|
|
1067
1068
|
* Hook that returns mutation options for use with useMutation.
|
|
1068
1069
|
* Wraps the Convex mutation with auth guard logic.
|
package/dist/react/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { A as
|
|
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-BHk8eMnX.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";
|
|
@@ -12,7 +12,7 @@ import { ConvexHttpClient } from "convex/browser";
|
|
|
12
12
|
//#region src/shared/meta-utils.ts
|
|
13
13
|
const metaCache = /* @__PURE__ */ new WeakMap();
|
|
14
14
|
const nonMetaLeafKeys = new Set(["functionRef", "ref"]);
|
|
15
|
-
function isRecord(value) {
|
|
15
|
+
function isRecord$1(value) {
|
|
16
16
|
return typeof value === "object" && value !== null;
|
|
17
17
|
}
|
|
18
18
|
function isFunctionType(value) {
|
|
@@ -34,10 +34,10 @@ function extractLeafMeta(value) {
|
|
|
34
34
|
}
|
|
35
35
|
function getHttpRoutes(api) {
|
|
36
36
|
const routes = api._http;
|
|
37
|
-
if (!isRecord(routes)) return;
|
|
37
|
+
if (!isRecord$1(routes)) return;
|
|
38
38
|
const normalized = {};
|
|
39
39
|
for (const [routeKey, routeValue] of Object.entries(routes)) {
|
|
40
|
-
if (!isRecord(routeValue)) continue;
|
|
40
|
+
if (!isRecord$1(routeValue)) continue;
|
|
41
41
|
const routePath = routeValue.path;
|
|
42
42
|
const routeMethod = routeValue.method;
|
|
43
43
|
if (typeof routePath === "string" && typeof routeMethod === "string") normalized[routeKey] = {
|
|
@@ -60,7 +60,7 @@ function buildMetaIndex(api) {
|
|
|
60
60
|
const walk = (node, path) => {
|
|
61
61
|
for (const [key, value] of Object.entries(node)) {
|
|
62
62
|
if (key.startsWith("_")) continue;
|
|
63
|
-
if (!isRecord(value)) continue;
|
|
63
|
+
if (!isRecord$1(value)) continue;
|
|
64
64
|
const leafMeta = extractLeafMeta(value);
|
|
65
65
|
if (leafMeta) {
|
|
66
66
|
if (path.length === 0) continue;
|
|
@@ -798,6 +798,49 @@ function createHashFn(fallback = hashKey) {
|
|
|
798
798
|
};
|
|
799
799
|
}
|
|
800
800
|
|
|
801
|
+
//#endregion
|
|
802
|
+
//#region src/internal/shallow.ts
|
|
803
|
+
/**
|
|
804
|
+
* Framework-free shallow comparison helpers.
|
|
805
|
+
*
|
|
806
|
+
* The bindings use these to keep object identity stable across renders when
|
|
807
|
+
* nothing observable changed, so TanStack Query's `shallowEqualObjects` guards
|
|
808
|
+
* and React dependency arrays can actually hit.
|
|
809
|
+
*/
|
|
810
|
+
/** True when `value` is a non-null object. */
|
|
811
|
+
function isRecord(value) {
|
|
812
|
+
return typeof value === "object" && value !== null;
|
|
813
|
+
}
|
|
814
|
+
/**
|
|
815
|
+
* Compare own enumerable string keys with `Object.is`.
|
|
816
|
+
*
|
|
817
|
+
* Deliberately shallow, never deep: option values are frequently closures
|
|
818
|
+
* (`select`, `retry`, function-form `placeholderData`) that capture fresh
|
|
819
|
+
* render scope, and treating a stale closure as equal would serve stale data.
|
|
820
|
+
*/
|
|
821
|
+
function isShallowEqual(a, b) {
|
|
822
|
+
if (a === b) return true;
|
|
823
|
+
const keys = Object.keys(a);
|
|
824
|
+
if (keys.length !== Object.keys(b).length) return false;
|
|
825
|
+
const left = a;
|
|
826
|
+
const right = b;
|
|
827
|
+
for (const key of keys) {
|
|
828
|
+
if (!Object.hasOwn(right, key)) return false;
|
|
829
|
+
if (!Object.is(left[key], right[key])) return false;
|
|
830
|
+
}
|
|
831
|
+
return true;
|
|
832
|
+
}
|
|
833
|
+
|
|
834
|
+
//#endregion
|
|
835
|
+
//#region src/internal/use-stable-identity.ts
|
|
836
|
+
function useStableIdentity(value, isEqual = isShallowEqual) {
|
|
837
|
+
const previousRef = useRef(null);
|
|
838
|
+
const previous = previousRef.current;
|
|
839
|
+
if (previous !== null && isEqual(previous, value)) return previous;
|
|
840
|
+
previousRef.current = value;
|
|
841
|
+
return value;
|
|
842
|
+
}
|
|
843
|
+
|
|
801
844
|
//#endregion
|
|
802
845
|
//#region src/react/use-query-options.ts
|
|
803
846
|
/** biome-ignore-all lint/suspicious/noExplicitAny: Convex type compatibility */
|
|
@@ -807,22 +850,28 @@ function createHashFn(fallback = hashKey) {
|
|
|
807
850
|
*/
|
|
808
851
|
const EMPTY_ARGS = {};
|
|
809
852
|
const hashConvexOptionsKey = createHashFn();
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
const
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
853
|
+
/**
|
|
854
|
+
* Compare two computed option objects for observable equivalence.
|
|
855
|
+
*
|
|
856
|
+
* Top-level values are compared by reference so inline `select` /
|
|
857
|
+
* `placeholderData` closures are never treated as equal. `meta` is exempt: it
|
|
858
|
+
* is rebuilt from scalars by these hooks on every render, so comparing its
|
|
859
|
+
* identity would defeat the whole check.
|
|
860
|
+
*/
|
|
861
|
+
function areQueryOptionsEquivalent(a, b) {
|
|
862
|
+
const keys = Object.keys(a);
|
|
863
|
+
if (keys.length !== Object.keys(b).length) return false;
|
|
864
|
+
const left = a;
|
|
865
|
+
const right = b;
|
|
866
|
+
for (const key of keys) {
|
|
867
|
+
if (!Object.hasOwn(right, key)) return false;
|
|
868
|
+
const previous = left[key];
|
|
869
|
+
const next = right[key];
|
|
870
|
+
if (Object.is(previous, next)) continue;
|
|
871
|
+
if (key === "meta" && isRecord(previous) && isRecord(next) && isShallowEqual(previous, next)) continue;
|
|
872
|
+
return false;
|
|
824
873
|
}
|
|
825
|
-
return
|
|
874
|
+
return true;
|
|
826
875
|
}
|
|
827
876
|
function useStableQueryArgs(prefix, funcRef, args) {
|
|
828
877
|
const resolvedArgs = args === skipToken || args == null ? EMPTY_ARGS : args;
|
|
@@ -831,7 +880,7 @@ function useStableQueryArgs(prefix, funcRef, args) {
|
|
|
831
880
|
getFunctionName(funcRef),
|
|
832
881
|
resolvedArgs
|
|
833
882
|
]);
|
|
834
|
-
const value = useMemo(() =>
|
|
883
|
+
const value = useMemo(() => structuredClone(resolvedArgs), [argsHash]);
|
|
835
884
|
return useMemo(() => ({
|
|
836
885
|
hash: argsHash,
|
|
837
886
|
value
|
|
@@ -870,7 +919,7 @@ function useConvexQueryOptions(funcRef, args, options) {
|
|
|
870
919
|
});
|
|
871
920
|
const stableArgs = useStableQueryArgs("convexQuery", funcRef, isSkipped ? EMPTY_ARGS : args);
|
|
872
921
|
const baseOptions = useMemo(() => convexQuery(funcRef, stableArgs.value), [funcRef, stableArgs]);
|
|
873
|
-
return useMemo(() => {
|
|
922
|
+
return useStableIdentity(useMemo(() => {
|
|
874
923
|
const { enabled: userEnabled, skipUnauth, subscribe, ...queryOptions } = options ?? {};
|
|
875
924
|
return {
|
|
876
925
|
...baseOptions,
|
|
@@ -889,7 +938,7 @@ function useConvexQueryOptions(funcRef, args, options) {
|
|
|
889
938
|
isSkipped,
|
|
890
939
|
options,
|
|
891
940
|
shouldSkip
|
|
892
|
-
]);
|
|
941
|
+
]), areQueryOptionsEquivalent);
|
|
893
942
|
}
|
|
894
943
|
/**
|
|
895
944
|
* Hook that returns infinite query options for use with useInfiniteQuery.
|
|
@@ -965,7 +1014,7 @@ function useConvexActionQueryOptions(action, args, options) {
|
|
|
965
1014
|
});
|
|
966
1015
|
const stableArgs = useStableQueryArgs("convexAction", action, isSkipped ? EMPTY_ARGS : args);
|
|
967
1016
|
const baseOptions = useMemo(() => convexAction(action, stableArgs.value), [action, stableArgs]);
|
|
968
|
-
return useMemo(() => {
|
|
1017
|
+
return useStableIdentity(useMemo(() => {
|
|
969
1018
|
const { enabled: userEnabled, skipUnauth, ...queryOptions } = options ?? {};
|
|
970
1019
|
return {
|
|
971
1020
|
...baseOptions,
|
|
@@ -983,7 +1032,7 @@ function useConvexActionQueryOptions(action, args, options) {
|
|
|
983
1032
|
isSkipped,
|
|
984
1033
|
options,
|
|
985
1034
|
shouldSkip
|
|
986
|
-
]);
|
|
1035
|
+
]), areQueryOptionsEquivalent);
|
|
987
1036
|
}
|
|
988
1037
|
/**
|
|
989
1038
|
* Hook that returns mutation options for use with useMutation.
|
|
@@ -1280,6 +1329,17 @@ function useFnMeta() {
|
|
|
1280
1329
|
return (namespace, fnName) => meta?.[namespace]?.[fnName];
|
|
1281
1330
|
}
|
|
1282
1331
|
/**
|
|
1332
|
+
* Stable signature of the current auth identity.
|
|
1333
|
+
*
|
|
1334
|
+
* JWTs collapse to their non-volatile claims so a refresh is a no-op; anything
|
|
1335
|
+
* that is not a JWT keeps its own signature so opaque-token transitions and
|
|
1336
|
+
* logout still register.
|
|
1337
|
+
*/
|
|
1338
|
+
function resolveAuthIdentity(token) {
|
|
1339
|
+
if (token === null) return null;
|
|
1340
|
+
return decodeJwtIdentity(token) ?? `opaque:${token}`;
|
|
1341
|
+
}
|
|
1342
|
+
/**
|
|
1283
1343
|
* Create CRPC context, provider, and hooks for a Convex API.
|
|
1284
1344
|
*
|
|
1285
1345
|
* @param options - Configuration object containing api and optional HTTP settings
|
|
@@ -1312,7 +1372,6 @@ function createCRPCContext(options) {
|
|
|
1312
1372
|
const meta = buildMetaIndex(api);
|
|
1313
1373
|
const CRPCProxyContext = createContext(null);
|
|
1314
1374
|
const VanillaClientContext = createContext(null);
|
|
1315
|
-
const HttpProxyContext = createContext(void 0);
|
|
1316
1375
|
/** Inner provider */
|
|
1317
1376
|
function CRPCProviderInner({ children, convexClient, convexQueryClient }) {
|
|
1318
1377
|
const authStore = useAuthStore();
|
|
@@ -1323,12 +1382,13 @@ function createCRPCContext(options) {
|
|
|
1323
1382
|
useEffect(() => {
|
|
1324
1383
|
const previous = previousAuthRef.current;
|
|
1325
1384
|
const tokenReady = token === null || decodeJwtExp(token) !== null;
|
|
1385
|
+
const identity = resolveAuthIdentity(token);
|
|
1326
1386
|
previousAuthRef.current = {
|
|
1327
1387
|
isAuthenticated,
|
|
1328
|
-
|
|
1388
|
+
identity
|
|
1329
1389
|
};
|
|
1330
1390
|
if (!previous) return;
|
|
1331
|
-
if (tokenReady && (previous.
|
|
1391
|
+
if (tokenReady && (previous.identity !== identity || previous.isAuthenticated !== isAuthenticated)) convexQueryClient.resetAuthQueries();
|
|
1332
1392
|
}, [
|
|
1333
1393
|
convexQueryClient,
|
|
1334
1394
|
isAuthenticated,
|
|
@@ -1363,18 +1423,29 @@ function createCRPCContext(options) {
|
|
|
1363
1423
|
}, [authStore, fetchAccessToken]);
|
|
1364
1424
|
const proxy = useMemo(() => createCRPCOptionsProxy(api, meta, options.transformer), []);
|
|
1365
1425
|
const vanillaClient = useMemo(() => createVanillaCRPCProxy(api, meta, convexClient, options.transformer), [convexClient]);
|
|
1426
|
+
const mergedProxy = useMemo(() => {
|
|
1427
|
+
if (!httpProxy) return proxy;
|
|
1428
|
+
return new Proxy(proxy, { get(target, prop) {
|
|
1429
|
+
if (prop === "http") return httpProxy;
|
|
1430
|
+
return Reflect.get(target, prop);
|
|
1431
|
+
} });
|
|
1432
|
+
}, [httpProxy, proxy]);
|
|
1433
|
+
const mergedClient = useMemo(() => {
|
|
1434
|
+
if (!httpProxy) return vanillaClient;
|
|
1435
|
+
return new Proxy(vanillaClient, { get(target, prop) {
|
|
1436
|
+
if (prop === "http") return httpProxy;
|
|
1437
|
+
return Reflect.get(target, prop);
|
|
1438
|
+
} });
|
|
1439
|
+
}, [httpProxy, vanillaClient]);
|
|
1366
1440
|
return /* @__PURE__ */ jsx(ConvexQueryClientContext.Provider, {
|
|
1367
1441
|
value: convexQueryClient,
|
|
1368
1442
|
children: /* @__PURE__ */ jsx(MetaContext.Provider, {
|
|
1369
1443
|
value: meta,
|
|
1370
1444
|
children: /* @__PURE__ */ jsx(VanillaClientContext.Provider, {
|
|
1371
|
-
value:
|
|
1372
|
-
children: /* @__PURE__ */ jsx(
|
|
1373
|
-
value:
|
|
1374
|
-
children
|
|
1375
|
-
value: proxy,
|
|
1376
|
-
children
|
|
1377
|
-
})
|
|
1445
|
+
value: mergedClient,
|
|
1446
|
+
children: /* @__PURE__ */ jsx(CRPCProxyContext.Provider, {
|
|
1447
|
+
value: mergedProxy,
|
|
1448
|
+
children
|
|
1378
1449
|
})
|
|
1379
1450
|
})
|
|
1380
1451
|
})
|
|
@@ -1408,12 +1479,7 @@ function createCRPCContext(options) {
|
|
|
1408
1479
|
*/
|
|
1409
1480
|
function useCRPC() {
|
|
1410
1481
|
const ctx = useContext(CRPCProxyContext);
|
|
1411
|
-
const httpProxy = useContext(HttpProxyContext);
|
|
1412
1482
|
if (!ctx) throw new Error("useCRPC must be used within CRPCProvider");
|
|
1413
|
-
if (httpProxy) return new Proxy(ctx, { get(target, prop) {
|
|
1414
|
-
if (prop === "http") return httpProxy;
|
|
1415
|
-
return Reflect.get(target, prop);
|
|
1416
|
-
} });
|
|
1417
1483
|
return ctx;
|
|
1418
1484
|
}
|
|
1419
1485
|
/**
|
|
@@ -1436,12 +1502,7 @@ function createCRPCContext(options) {
|
|
|
1436
1502
|
*/
|
|
1437
1503
|
function useCRPCClient() {
|
|
1438
1504
|
const ctx = useContext(VanillaClientContext);
|
|
1439
|
-
const httpProxy = useContext(HttpProxyContext);
|
|
1440
1505
|
if (!ctx) throw new Error("useCRPCClient must be used within CRPCProvider");
|
|
1441
|
-
if (httpProxy) return new Proxy(ctx, { get(target, prop) {
|
|
1442
|
-
if (prop === "http") return httpProxy;
|
|
1443
|
-
return Reflect.get(target, prop);
|
|
1444
|
-
} });
|
|
1445
1506
|
return ctx;
|
|
1446
1507
|
}
|
|
1447
1508
|
return {
|
|
@@ -1720,6 +1781,19 @@ function isConvexAction(queryKey) {
|
|
|
1720
1781
|
return queryKey.length >= 2 && queryKey[0] === "convexAction";
|
|
1721
1782
|
}
|
|
1722
1783
|
/**
|
|
1784
|
+
* Write a subscription value into an already-resolved Query.
|
|
1785
|
+
*
|
|
1786
|
+
* Going through the Query skips the query-key re-hash that the key-based
|
|
1787
|
+
* `getQueryData` / `setQueryData` pair pays on every push. `setQueryData`
|
|
1788
|
+
* short-circuits on `undefined` and `Query.setData` does not, so the guard has
|
|
1789
|
+
* to be reproduced here: without it a never-resolved subscription would flip to
|
|
1790
|
+
* `status: 'success'` with `data: undefined`.
|
|
1791
|
+
*/
|
|
1792
|
+
function writeQueryData(query, value) {
|
|
1793
|
+
if (value === void 0) return;
|
|
1794
|
+
query.setData(value, { manual: true });
|
|
1795
|
+
}
|
|
1796
|
+
/**
|
|
1723
1797
|
* Bridges TanStack Query with Convex real-time subscriptions.
|
|
1724
1798
|
*
|
|
1725
1799
|
* ## Setup
|
|
@@ -1812,15 +1886,12 @@ var ConvexQueryClient = class {
|
|
|
1812
1886
|
const meta = query.meta;
|
|
1813
1887
|
return meta?.authType === "required" || meta?.authType === "optional";
|
|
1814
1888
|
}
|
|
1815
|
-
isQueryDisabled(query) {
|
|
1816
|
-
return query.isDisabled();
|
|
1817
|
-
}
|
|
1818
1889
|
subscribeQuery(query) {
|
|
1819
1890
|
if (this.subscriptions[query.queryHash]) return;
|
|
1820
1891
|
const meta = query.meta;
|
|
1821
1892
|
if (meta?.subscribe === false) return;
|
|
1822
1893
|
if (query.getObserversCount() === 0) return;
|
|
1823
|
-
if (
|
|
1894
|
+
if (query.isDisabled()) return;
|
|
1824
1895
|
if (this.shouldSkipSubscription(meta?.authType)) return;
|
|
1825
1896
|
const [, funcName, args] = query.queryKey;
|
|
1826
1897
|
const watch = this.convexClient.watchQuery(funcName, this.transformer.input.serialize(args));
|
|
@@ -1958,15 +2029,15 @@ var ConvexQueryClient = class {
|
|
|
1958
2029
|
};
|
|
1959
2030
|
}
|
|
1960
2031
|
if (result.ok) {
|
|
1961
|
-
const existingData =
|
|
1962
|
-
if (result.value !== void 0 || !(existingData !== void 0))
|
|
2032
|
+
const existingData = query.state.data;
|
|
2033
|
+
if (result.value !== void 0 || !(existingData !== void 0)) writeQueryData(query, this.transformer.output.deserialize(result.value));
|
|
1963
2034
|
} else {
|
|
1964
2035
|
const { error } = result;
|
|
1965
2036
|
const authState = this.getAuthState();
|
|
1966
2037
|
const meta = query.meta;
|
|
1967
2038
|
const isUnauthorized = authState?.isUnauthorized(error) ?? false;
|
|
1968
2039
|
if (isUnauthorized && meta?.skipUnauth) {
|
|
1969
|
-
|
|
2040
|
+
writeQueryData(query, this.transformer.output.deserialize(null));
|
|
1970
2041
|
return;
|
|
1971
2042
|
}
|
|
1972
2043
|
query.setState({
|
|
@@ -2023,7 +2094,7 @@ var ConvexQueryClient = class {
|
|
|
2023
2094
|
if (event.action.type === "setState" && event.action.setStateOptions?.meta === "set by ConvexQueryClient") break;
|
|
2024
2095
|
break;
|
|
2025
2096
|
case "observerOptionsUpdated": {
|
|
2026
|
-
const isDisabled =
|
|
2097
|
+
const isDisabled = event.query.isDisabled();
|
|
2027
2098
|
const isSubscribed = !!this.subscriptions[event.query.queryHash];
|
|
2028
2099
|
if (isDisabled && isSubscribed) {
|
|
2029
2100
|
this.cancelPendingUnsubscribe(event.query.queryHash);
|
|
@@ -2289,7 +2360,8 @@ const useStaleCursorRecovery = ({ argsObject, combined, limit, setState, state }
|
|
|
2289
2360
|
* Use `useInfiniteQuery` for the public API with auth handling.
|
|
2290
2361
|
*/
|
|
2291
2362
|
const useInfiniteQueryInternal = (query, args, options) => {
|
|
2292
|
-
const { limit, enabled, placeholderData, ...
|
|
2363
|
+
const { limit, enabled, placeholderData, ...forwardedOptions } = options;
|
|
2364
|
+
const queryOptions = useStableIdentity(forwardedOptions);
|
|
2293
2365
|
const { isLoading: isAuthLoading } = useSafeConvexAuth();
|
|
2294
2366
|
const meta = useMeta();
|
|
2295
2367
|
const queryClient = useQueryClient();
|
|
@@ -2433,7 +2505,7 @@ const useInfiniteQueryInternal = (query, args, options) => {
|
|
|
2433
2505
|
prefetchedFirstPage,
|
|
2434
2506
|
placeholderData
|
|
2435
2507
|
]),
|
|
2436
|
-
combine: (results) => {
|
|
2508
|
+
combine: useCallback((results) => {
|
|
2437
2509
|
const allItems = [];
|
|
2438
2510
|
const pages = [];
|
|
2439
2511
|
const seenIds = /* @__PURE__ */ new Set();
|
|
@@ -2474,7 +2546,7 @@ const useInfiniteQueryInternal = (query, args, options) => {
|
|
|
2474
2546
|
isRefetching: isFetching && allItems.length > 0 && !isPlaceholderData,
|
|
2475
2547
|
_rawResults: results
|
|
2476
2548
|
};
|
|
2477
|
-
}
|
|
2549
|
+
}, [placeholderData])
|
|
2478
2550
|
});
|
|
2479
2551
|
useStaleCursorRecovery({
|
|
2480
2552
|
argsObject,
|
|
@@ -2556,6 +2628,13 @@ const useInfiniteQueryInternal = (query, args, options) => {
|
|
|
2556
2628
|
setState,
|
|
2557
2629
|
argsObject
|
|
2558
2630
|
]);
|
|
2631
|
+
const loadMoreRef = useRef(loadMore);
|
|
2632
|
+
const limitRef = useRef(limit);
|
|
2633
|
+
useEffect(() => {
|
|
2634
|
+
loadMoreRef.current = loadMore;
|
|
2635
|
+
limitRef.current = limit;
|
|
2636
|
+
}, [loadMore, limit]);
|
|
2637
|
+
const fetchNextPage = useCallback((n) => loadMoreRef.current(n ?? limitRef.current), []);
|
|
2559
2638
|
const { _rawResults, lastPage, ...result } = combined;
|
|
2560
2639
|
const hasNextPage = combined.status === "CanLoadMore";
|
|
2561
2640
|
const isFetchingNextPage = combined.status === "LoadingMore";
|
|
@@ -2563,7 +2642,7 @@ const useInfiniteQueryInternal = (query, args, options) => {
|
|
|
2563
2642
|
...result,
|
|
2564
2643
|
failureReason: combined.failureReason,
|
|
2565
2644
|
error: combined.error instanceof Error ? combined.error : null,
|
|
2566
|
-
fetchNextPage
|
|
2645
|
+
fetchNextPage,
|
|
2567
2646
|
hasNextPage,
|
|
2568
2647
|
isFetchingNextPage
|
|
2569
2648
|
};
|
|
@@ -2608,10 +2687,11 @@ function useInfiniteQuery(infiniteOptions) {
|
|
|
2608
2687
|
queryName,
|
|
2609
2688
|
onQueryUnauthorized
|
|
2610
2689
|
]);
|
|
2690
|
+
const enabled = useMemo(() => resolveEnabled(!shouldSkip, factoryEnabled), [shouldSkip, factoryEnabled]);
|
|
2611
2691
|
const result = useInfiniteQueryInternal(query, args, {
|
|
2612
2692
|
limit,
|
|
2613
2693
|
...queryOptions,
|
|
2614
|
-
enabled
|
|
2694
|
+
enabled
|
|
2615
2695
|
});
|
|
2616
2696
|
const authLoadingApplies = authType === "optional" || authType === "required";
|
|
2617
2697
|
const isClientError = isCRPCClientError(result.error);
|
|
@@ -4505,22 +4505,22 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4505
4505
|
fieldName: "status";
|
|
4506
4506
|
};
|
|
4507
4507
|
};
|
|
4508
|
-
|
|
4508
|
+
direction: ConvexTextBuilderInitial<""> & {
|
|
4509
4509
|
_: {
|
|
4510
4510
|
tableName: "migration_state";
|
|
4511
4511
|
};
|
|
4512
4512
|
} & {
|
|
4513
4513
|
_: {
|
|
4514
|
-
fieldName: "
|
|
4514
|
+
fieldName: "direction";
|
|
4515
4515
|
};
|
|
4516
4516
|
};
|
|
4517
|
-
|
|
4517
|
+
cursor: ConvexTextBuilderInitial<""> & {
|
|
4518
4518
|
_: {
|
|
4519
4519
|
tableName: "migration_state";
|
|
4520
4520
|
};
|
|
4521
4521
|
} & {
|
|
4522
4522
|
_: {
|
|
4523
|
-
fieldName: "
|
|
4523
|
+
fieldName: "cursor";
|
|
4524
4524
|
};
|
|
4525
4525
|
};
|
|
4526
4526
|
updatedAt: ConvexNumberBuilderInitial<""> & {
|