kitcn 0.12.9 → 0.12.10
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.js +32 -8
- package/dist/orm/index.d.ts +1 -1
- package/dist/react/index.d.ts +5 -1
- package/dist/react/index.js +67 -47
- package/dist/{where-clause-compiler-Dw3EVdi6.d.ts → where-clause-compiler-DdjN63Io.d.ts} +23 -23
- 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-DdjN63Io.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";
|
|
@@ -52,6 +52,13 @@ function ConvexAuthProviderInner({ children, client, authClient }) {
|
|
|
52
52
|
const pendingTokenRef = useRef(null);
|
|
53
53
|
sessionRef.current = session;
|
|
54
54
|
isPendingRef.current = isPending;
|
|
55
|
+
const getCachedJwt = useCallback((minTimeRemainingMs = 0) => {
|
|
56
|
+
const cachedToken = authStore.get("token");
|
|
57
|
+
if (!cachedToken) return null;
|
|
58
|
+
const expiresAt = decodeJwtExp(cachedToken);
|
|
59
|
+
if (expiresAt === null || expiresAt <= Date.now() + minTimeRemainingMs) return null;
|
|
60
|
+
return cachedToken;
|
|
61
|
+
}, [authStore]);
|
|
55
62
|
useEffect(() => {
|
|
56
63
|
if (hasActiveSessionData(session)) {
|
|
57
64
|
authStore.set("sessionSyncGraceUntil", null);
|
|
@@ -86,11 +93,23 @@ function ConvexAuthProviderInner({ children, client, authClient }) {
|
|
|
86
93
|
authStore.set("sessionSyncGraceUntil", null);
|
|
87
94
|
return jwt;
|
|
88
95
|
}
|
|
96
|
+
const cachedJwt = getCachedJwt();
|
|
97
|
+
if (cachedJwt) {
|
|
98
|
+
authStore.set("expiresAt", decodeJwtExp(cachedJwt));
|
|
99
|
+
authStore.set("sessionSyncGraceUntil", null);
|
|
100
|
+
return cachedJwt;
|
|
101
|
+
}
|
|
89
102
|
authStore.set("token", null);
|
|
90
103
|
authStore.set("expiresAt", null);
|
|
91
104
|
authStore.set("sessionSyncGraceUntil", null);
|
|
92
105
|
return null;
|
|
93
106
|
}).catch((error) => {
|
|
107
|
+
const cachedJwt = getCachedJwt();
|
|
108
|
+
if (cachedJwt) {
|
|
109
|
+
authStore.set("expiresAt", decodeJwtExp(cachedJwt));
|
|
110
|
+
authStore.set("sessionSyncGraceUntil", null);
|
|
111
|
+
return cachedJwt;
|
|
112
|
+
}
|
|
94
113
|
authStore.set("token", null);
|
|
95
114
|
authStore.set("expiresAt", null);
|
|
96
115
|
authStore.set("sessionSyncGraceUntil", null);
|
|
@@ -102,9 +121,10 @@ function ConvexAuthProviderInner({ children, client, authClient }) {
|
|
|
102
121
|
return pendingTokenRef.current;
|
|
103
122
|
};
|
|
104
123
|
const fetchFreshTokenForced = async () => {
|
|
124
|
+
const cachedJwt = getCachedJwt();
|
|
105
125
|
if (pendingTokenRef.current) {
|
|
106
126
|
const token = await pendingTokenRef.current;
|
|
107
|
-
if (token) return token;
|
|
127
|
+
if (token && (!cachedJwt || token !== cachedJwt)) return token;
|
|
108
128
|
}
|
|
109
129
|
return fetchFreshToken();
|
|
110
130
|
};
|
|
@@ -114,16 +134,16 @@ function ConvexAuthProviderInner({ children, client, authClient }) {
|
|
|
114
134
|
const hasSessionSyncGrace = isSessionSyncGraceActive(authStore.get("sessionSyncGraceUntil"));
|
|
115
135
|
if (!hasSession) {
|
|
116
136
|
if (currentIsPending || hasSessionSyncGrace) {
|
|
117
|
-
const
|
|
137
|
+
const cachedJwt = getCachedJwt();
|
|
118
138
|
if (!forceRefreshToken) {
|
|
119
|
-
if (
|
|
139
|
+
if (cachedJwt) return cachedJwt;
|
|
120
140
|
return fetchFreshToken();
|
|
121
141
|
}
|
|
122
142
|
const freshToken = await fetchFreshTokenForced();
|
|
123
|
-
if (!freshToken &&
|
|
124
|
-
authStore.set("token",
|
|
125
|
-
authStore.set("expiresAt", decodeJwtExp(
|
|
126
|
-
return
|
|
143
|
+
if (!freshToken && cachedJwt) {
|
|
144
|
+
authStore.set("token", cachedJwt);
|
|
145
|
+
authStore.set("expiresAt", decodeJwtExp(cachedJwt));
|
|
146
|
+
return cachedJwt;
|
|
127
147
|
}
|
|
128
148
|
return freshToken;
|
|
129
149
|
}
|
|
@@ -139,7 +159,11 @@ function ConvexAuthProviderInner({ children, client, authClient }) {
|
|
|
139
159
|
if (!forceRefreshToken && pendingTokenRef.current) return pendingTokenRef.current;
|
|
140
160
|
if (forceRefreshToken) return fetchFreshTokenForced();
|
|
141
161
|
return fetchFreshToken();
|
|
142
|
-
}, [
|
|
162
|
+
}, [
|
|
163
|
+
authStore,
|
|
164
|
+
authClient,
|
|
165
|
+
getCachedJwt
|
|
166
|
+
]);
|
|
143
167
|
const useAuth = useCallback(function useConvexAuthHook() {
|
|
144
168
|
const token = authStore.get("token");
|
|
145
169
|
const hasSession = hasActiveSessionData(sessionRef.current);
|
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-DdjN63Io.js";
|
|
2
2
|
import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-vzRKjBJC.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-CFZqIvD7.js";
|
|
4
4
|
import { DefineSchemaOptions, GenericDatabaseReader, GenericDatabaseWriter, GenericSchema, SchemaDefinition } from "convex/server";
|
package/dist/react/index.d.ts
CHANGED
|
@@ -350,7 +350,7 @@ declare class ConvexQueryClient {
|
|
|
350
350
|
subscriptions: Record<string, {
|
|
351
351
|
watch: Watch<unknown>;
|
|
352
352
|
unsubscribe: () => void;
|
|
353
|
-
queryKey:
|
|
353
|
+
queryKey: QueryKey;
|
|
354
354
|
}>;
|
|
355
355
|
/** Cleanup function for QueryCache subscription */
|
|
356
356
|
unsubscribe: (() => void) | undefined;
|
|
@@ -377,6 +377,9 @@ declare class ConvexQueryClient {
|
|
|
377
377
|
private cancelPendingUnsubscribe;
|
|
378
378
|
/** Unsubscribe a live Convex watch (if present) and remove it from the subscription map. */
|
|
379
379
|
private unsubscribeQueryByHash;
|
|
380
|
+
private isAuthBoundQuery;
|
|
381
|
+
private isQueryDisabled;
|
|
382
|
+
private subscribeQuery;
|
|
380
383
|
/** Update auth store (for HMR where jotai store may reset) */
|
|
381
384
|
updateAuthStore(authStore?: AuthStore): void;
|
|
382
385
|
/** Get current auth state from store */
|
|
@@ -411,6 +414,7 @@ declare class ConvexQueryClient {
|
|
|
411
414
|
* Call before logout to prevent UNAUTHORIZED errors during session invalidation.
|
|
412
415
|
*/
|
|
413
416
|
unsubscribeAuthQueries(): void;
|
|
417
|
+
resetAuthQueries(): Promise<void>;
|
|
414
418
|
/**
|
|
415
419
|
* Batch update all subscriptions.
|
|
416
420
|
* Called internally when Convex client reconnects.
|
package/dist/react/index.js
CHANGED
|
@@ -1185,7 +1185,24 @@ function createCRPCContext(options) {
|
|
|
1185
1185
|
/** Inner provider */
|
|
1186
1186
|
function CRPCProviderInner({ children, convexClient, convexQueryClient }) {
|
|
1187
1187
|
const authStore = useAuthStore();
|
|
1188
|
+
const token = useAuthValue("token");
|
|
1189
|
+
const isAuthenticated = useAuthValue("isAuthenticated");
|
|
1190
|
+
const previousAuthRef = useRef(null);
|
|
1188
1191
|
const fetchAccessToken = useFetchAccessToken();
|
|
1192
|
+
useEffect(() => {
|
|
1193
|
+
const previous = previousAuthRef.current;
|
|
1194
|
+
const tokenReady = token === null || decodeJwtExp(token) !== null;
|
|
1195
|
+
previousAuthRef.current = {
|
|
1196
|
+
isAuthenticated,
|
|
1197
|
+
token
|
|
1198
|
+
};
|
|
1199
|
+
if (!previous) return;
|
|
1200
|
+
if (tokenReady && (previous.token !== token || previous.isAuthenticated !== isAuthenticated)) convexQueryClient.resetAuthQueries();
|
|
1201
|
+
}, [
|
|
1202
|
+
convexQueryClient,
|
|
1203
|
+
isAuthenticated,
|
|
1204
|
+
token
|
|
1205
|
+
]);
|
|
1189
1206
|
const httpProxy = useMemo(() => {
|
|
1190
1207
|
if (!httpOptions.convexSiteUrl || !meta._http) return;
|
|
1191
1208
|
return createHttpProxy({
|
|
@@ -1438,12 +1455,14 @@ function createAuthMutations(authClient) {
|
|
|
1438
1455
|
authStoreApi.set("token", null);
|
|
1439
1456
|
authStoreApi.set("expiresAt", null);
|
|
1440
1457
|
authStoreApi.set("sessionSyncGraceUntil", null);
|
|
1458
|
+
await convexQueryClient?.resetAuthQueries();
|
|
1441
1459
|
return res;
|
|
1442
1460
|
}
|
|
1443
1461
|
};
|
|
1444
1462
|
});
|
|
1445
1463
|
const useSignInSocialMutationOptions = ((options) => {
|
|
1446
1464
|
const authStoreApi = useAuthStore();
|
|
1465
|
+
const convexQueryClient = useConvexQueryClient();
|
|
1447
1466
|
return {
|
|
1448
1467
|
...options,
|
|
1449
1468
|
mutationFn: async (args) => {
|
|
@@ -1452,12 +1471,15 @@ function createAuthMutations(authClient) {
|
|
|
1452
1471
|
seedReturnedToken(authStoreApi, res);
|
|
1453
1472
|
await hydrateReturnedSession(authClient, res);
|
|
1454
1473
|
await ensureAuth(authStoreApi);
|
|
1474
|
+
authStoreApi.set("isAuthenticated", true);
|
|
1475
|
+
await convexQueryClient?.resetAuthQueries();
|
|
1455
1476
|
return res;
|
|
1456
1477
|
}
|
|
1457
1478
|
};
|
|
1458
1479
|
});
|
|
1459
1480
|
const useSignInMutationOptions = ((options) => {
|
|
1460
1481
|
const authStoreApi = useAuthStore();
|
|
1482
|
+
const convexQueryClient = useConvexQueryClient();
|
|
1461
1483
|
return {
|
|
1462
1484
|
...options,
|
|
1463
1485
|
mutationFn: async (args) => {
|
|
@@ -1466,12 +1488,15 @@ function createAuthMutations(authClient) {
|
|
|
1466
1488
|
seedReturnedToken(authStoreApi, res);
|
|
1467
1489
|
await hydrateReturnedSession(authClient, res);
|
|
1468
1490
|
await ensureAuth(authStoreApi);
|
|
1491
|
+
authStoreApi.set("isAuthenticated", true);
|
|
1492
|
+
await convexQueryClient?.resetAuthQueries();
|
|
1469
1493
|
return res;
|
|
1470
1494
|
}
|
|
1471
1495
|
};
|
|
1472
1496
|
});
|
|
1473
1497
|
const useSignUpMutationOptions = ((options) => {
|
|
1474
1498
|
const authStoreApi = useAuthStore();
|
|
1499
|
+
const convexQueryClient = useConvexQueryClient();
|
|
1475
1500
|
return {
|
|
1476
1501
|
...options,
|
|
1477
1502
|
mutationFn: async (args) => {
|
|
@@ -1480,6 +1505,8 @@ function createAuthMutations(authClient) {
|
|
|
1480
1505
|
seedReturnedToken(authStoreApi, res);
|
|
1481
1506
|
await hydrateReturnedSession(authClient, res);
|
|
1482
1507
|
await ensureAuth(authStoreApi);
|
|
1508
|
+
authStoreApi.set("isAuthenticated", true);
|
|
1509
|
+
await convexQueryClient?.resetAuthQueries();
|
|
1483
1510
|
return res;
|
|
1484
1511
|
}
|
|
1485
1512
|
};
|
|
@@ -1701,6 +1728,31 @@ var ConvexQueryClient = class {
|
|
|
1701
1728
|
sub.unsubscribe();
|
|
1702
1729
|
delete this.subscriptions[queryHash];
|
|
1703
1730
|
}
|
|
1731
|
+
isAuthBoundQuery(query) {
|
|
1732
|
+
const meta = query.meta;
|
|
1733
|
+
return meta?.authType === "required" || meta?.authType === "optional";
|
|
1734
|
+
}
|
|
1735
|
+
isQueryDisabled(query) {
|
|
1736
|
+
return query.isDisabled();
|
|
1737
|
+
}
|
|
1738
|
+
subscribeQuery(query) {
|
|
1739
|
+
if (this.subscriptions[query.queryHash]) return;
|
|
1740
|
+
const meta = query.meta;
|
|
1741
|
+
if (meta?.subscribe === false) return;
|
|
1742
|
+
if (query.getObserversCount() === 0) return;
|
|
1743
|
+
if (this.isQueryDisabled(query)) return;
|
|
1744
|
+
if (this.shouldSkipSubscription(meta?.authType)) return;
|
|
1745
|
+
const [, funcName, args] = query.queryKey;
|
|
1746
|
+
const watch = this.convexClient.watchQuery(funcName, this.transformer.input.serialize(args));
|
|
1747
|
+
const unsubscribe = watch.onUpdate(() => {
|
|
1748
|
+
this.onUpdateQueryKeyHash(query.queryHash);
|
|
1749
|
+
});
|
|
1750
|
+
this.subscriptions[query.queryHash] = {
|
|
1751
|
+
queryKey: query.queryKey,
|
|
1752
|
+
watch,
|
|
1753
|
+
unsubscribe
|
|
1754
|
+
};
|
|
1755
|
+
}
|
|
1704
1756
|
/** Update auth store (for HMR where jotai store may reset) */
|
|
1705
1757
|
updateAuthStore(authStore) {
|
|
1706
1758
|
this.authStore = authStore;
|
|
@@ -1783,6 +1835,15 @@ var ConvexQueryClient = class {
|
|
|
1783
1835
|
this.unsubscribeQueryByHash(queryHash);
|
|
1784
1836
|
}
|
|
1785
1837
|
}
|
|
1838
|
+
async resetAuthQueries() {
|
|
1839
|
+
const authQueries = this.queryClient.getQueryCache().getAll().filter((query) => this.isAuthBoundQuery(query));
|
|
1840
|
+
for (const query of authQueries) {
|
|
1841
|
+
this.cancelPendingUnsubscribe(query.queryHash);
|
|
1842
|
+
this.unsubscribeQueryByHash(query.queryHash);
|
|
1843
|
+
}
|
|
1844
|
+
await this.queryClient.resetQueries({ predicate: (query) => this.isAuthBoundQuery(query) });
|
|
1845
|
+
for (const query of this.queryClient.getQueryCache().getAll()) if (this.isAuthBoundQuery(query)) this.subscribeQuery(query);
|
|
1846
|
+
}
|
|
1786
1847
|
/**
|
|
1787
1848
|
* Batch update all subscriptions.
|
|
1788
1849
|
* Called internally when Convex client reconnects.
|
|
@@ -1860,42 +1921,13 @@ var ConvexQueryClient = class {
|
|
|
1860
1921
|
this.cancelPendingUnsubscribe(event.query.queryHash);
|
|
1861
1922
|
this.unsubscribeQueryByHash(event.query.queryHash);
|
|
1862
1923
|
break;
|
|
1863
|
-
case "added":
|
|
1864
|
-
|
|
1865
|
-
if (meta?.subscribe === false) break;
|
|
1866
|
-
const [, funcName, args] = event.query.queryKey;
|
|
1867
|
-
if (event.query.getObserversCount() === 0) break;
|
|
1868
|
-
if (this.shouldSkipSubscription(meta?.authType)) break;
|
|
1869
|
-
const watch = this.convexClient.watchQuery(funcName, this.transformer.input.serialize(args));
|
|
1870
|
-
const unsubscribe = watch.onUpdate(() => {
|
|
1871
|
-
this.onUpdateQueryKeyHash(event.query.queryHash);
|
|
1872
|
-
});
|
|
1873
|
-
this.subscriptions[event.query.queryHash] = {
|
|
1874
|
-
queryKey: event.query.queryKey,
|
|
1875
|
-
watch,
|
|
1876
|
-
unsubscribe
|
|
1877
|
-
};
|
|
1924
|
+
case "added":
|
|
1925
|
+
this.subscribeQuery(event.query);
|
|
1878
1926
|
break;
|
|
1879
|
-
|
|
1880
|
-
case "observerAdded": {
|
|
1927
|
+
case "observerAdded":
|
|
1881
1928
|
this.cancelPendingUnsubscribe(event.query.queryHash);
|
|
1882
|
-
|
|
1883
|
-
if (event.query.options.enabled === false) break;
|
|
1884
|
-
const meta = event.query.meta;
|
|
1885
|
-
if (meta?.subscribe === false) break;
|
|
1886
|
-
const [, funcName, args] = event.query.queryKey;
|
|
1887
|
-
if (this.shouldSkipSubscription(meta?.authType)) break;
|
|
1888
|
-
const watch = this.convexClient.watchQuery(funcName, this.transformer.input.serialize(args));
|
|
1889
|
-
const unsubscribe = watch.onUpdate(() => {
|
|
1890
|
-
this.onUpdateQueryKeyHash(event.query.queryHash);
|
|
1891
|
-
});
|
|
1892
|
-
this.subscriptions[event.query.queryHash] = {
|
|
1893
|
-
queryKey: event.query.queryKey,
|
|
1894
|
-
watch,
|
|
1895
|
-
unsubscribe
|
|
1896
|
-
};
|
|
1929
|
+
this.subscribeQuery(event.query);
|
|
1897
1930
|
break;
|
|
1898
|
-
}
|
|
1899
1931
|
case "observerRemoved":
|
|
1900
1932
|
if (event.query.getObserversCount() === 0 && this.subscriptions[event.query.queryHash]) {
|
|
1901
1933
|
const queryHash = event.query.queryHash;
|
|
@@ -1911,7 +1943,7 @@ var ConvexQueryClient = class {
|
|
|
1911
1943
|
if (event.action.type === "setState" && event.action.setStateOptions?.meta === "set by ConvexQueryClient") break;
|
|
1912
1944
|
break;
|
|
1913
1945
|
case "observerOptionsUpdated": {
|
|
1914
|
-
const isDisabled = event.query
|
|
1946
|
+
const isDisabled = this.isQueryDisabled(event.query);
|
|
1915
1947
|
const isSubscribed = !!this.subscriptions[event.query.queryHash];
|
|
1916
1948
|
if (isDisabled && isSubscribed) {
|
|
1917
1949
|
this.cancelPendingUnsubscribe(event.query.queryHash);
|
|
@@ -1919,19 +1951,7 @@ var ConvexQueryClient = class {
|
|
|
1919
1951
|
break;
|
|
1920
1952
|
}
|
|
1921
1953
|
if (isSubscribed || isDisabled) break;
|
|
1922
|
-
|
|
1923
|
-
if (meta?.subscribe === false) break;
|
|
1924
|
-
const [, funcName, args] = event.query.queryKey;
|
|
1925
|
-
if (this.shouldSkipSubscription(meta?.authType)) break;
|
|
1926
|
-
const watch = this.convexClient.watchQuery(funcName, this.transformer.input.serialize(args));
|
|
1927
|
-
const unsubscribe = watch.onUpdate(() => {
|
|
1928
|
-
this.onUpdateQueryKeyHash(event.query.queryHash);
|
|
1929
|
-
});
|
|
1930
|
-
this.subscriptions[event.query.queryHash] = {
|
|
1931
|
-
queryKey: event.query.queryKey,
|
|
1932
|
-
watch,
|
|
1933
|
-
unsubscribe
|
|
1934
|
-
};
|
|
1954
|
+
this.subscribeQuery(event.query);
|
|
1935
1955
|
break;
|
|
1936
1956
|
}
|
|
1937
1957
|
}
|
|
@@ -3717,6 +3717,19 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
3717
3717
|
readonly aggregate_bucket: ConvexTableWithColumns<{
|
|
3718
3718
|
name: "aggregate_bucket";
|
|
3719
3719
|
columns: {
|
|
3720
|
+
count: ConvexNumberBuilderInitial<""> & {
|
|
3721
|
+
_: {
|
|
3722
|
+
notNull: true;
|
|
3723
|
+
};
|
|
3724
|
+
} & {
|
|
3725
|
+
_: {
|
|
3726
|
+
tableName: "aggregate_bucket";
|
|
3727
|
+
};
|
|
3728
|
+
} & {
|
|
3729
|
+
_: {
|
|
3730
|
+
fieldName: "count";
|
|
3731
|
+
};
|
|
3732
|
+
};
|
|
3720
3733
|
tableKey: ConvexTextBuilderInitial<""> & {
|
|
3721
3734
|
_: {
|
|
3722
3735
|
notNull: true;
|
|
@@ -3786,19 +3799,6 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
3786
3799
|
fieldName: "keyParts";
|
|
3787
3800
|
};
|
|
3788
3801
|
};
|
|
3789
|
-
count: ConvexNumberBuilderInitial<""> & {
|
|
3790
|
-
_: {
|
|
3791
|
-
notNull: true;
|
|
3792
|
-
};
|
|
3793
|
-
} & {
|
|
3794
|
-
_: {
|
|
3795
|
-
tableName: "aggregate_bucket";
|
|
3796
|
-
};
|
|
3797
|
-
} & {
|
|
3798
|
-
_: {
|
|
3799
|
-
fieldName: "count";
|
|
3800
|
-
};
|
|
3801
|
-
};
|
|
3802
3802
|
sumValues: (NotNull<$Type<ConvexCustomBuilderInitial<"", convex_values0.VRecord<Record<string, any>, convex_values0.VString<string, "required">, convex_values0.VId<any, any> | convex_values0.VString<any, any> | convex_values0.VFloat64<any, any> | convex_values0.VInt64<any, any> | convex_values0.VBoolean<any, any> | convex_values0.VNull<any, any> | convex_values0.VAny<any, any, string> | convex_values0.VLiteral<any, any> | convex_values0.VBytes<any, any> | convex_values0.VObject<any, Record<string, convex_values0.Validator<any, convex_values0.OptionalProperty, any>>, any, any> | convex_values0.VArray<any, convex_values0.Validator<any, "required", any>, any> | convex_values0.VRecord<any, convex_values0.Validator<string, "required", any>, convex_values0.Validator<any, "required", any>, any, any> | convex_values0.VUnion<any, convex_values0.Validator<any, "required", any>[], any, any>, "required", string>>, Record<string, number>>> | NotNull<$Type<ConvexCustomBuilderInitial<"", convex_values0.VId<any, any> | convex_values0.VString<any, any> | convex_values0.VFloat64<any, any> | convex_values0.VInt64<any, any> | convex_values0.VBoolean<any, any> | convex_values0.VNull<any, any> | convex_values0.VAny<any, any, string> | convex_values0.VLiteral<any, any> | convex_values0.VBytes<any, any> | convex_values0.VObject<any, Record<string, convex_values0.Validator<any, convex_values0.OptionalProperty, any>>, any, any> | convex_values0.VArray<any, convex_values0.Validator<any, "required", any>, any> | convex_values0.VRecord<any, convex_values0.Validator<string, "required", any>, convex_values0.Validator<any, "required", any>, any, any> | convex_values0.VUnion<any, convex_values0.Validator<any, "required", any>[], any, any>>, Record<string, number>>>) & {
|
|
3803
3803
|
_: {
|
|
3804
3804
|
tableName: "aggregate_bucket";
|
|
@@ -4009,7 +4009,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4009
4009
|
fieldName: "value";
|
|
4010
4010
|
};
|
|
4011
4011
|
};
|
|
4012
|
-
|
|
4012
|
+
count: ConvexNumberBuilderInitial<""> & {
|
|
4013
4013
|
_: {
|
|
4014
4014
|
notNull: true;
|
|
4015
4015
|
};
|
|
@@ -4019,10 +4019,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4019
4019
|
};
|
|
4020
4020
|
} & {
|
|
4021
4021
|
_: {
|
|
4022
|
-
fieldName: "
|
|
4022
|
+
fieldName: "count";
|
|
4023
4023
|
};
|
|
4024
4024
|
};
|
|
4025
|
-
|
|
4025
|
+
tableKey: ConvexTextBuilderInitial<""> & {
|
|
4026
4026
|
_: {
|
|
4027
4027
|
notNull: true;
|
|
4028
4028
|
};
|
|
@@ -4032,10 +4032,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4032
4032
|
};
|
|
4033
4033
|
} & {
|
|
4034
4034
|
_: {
|
|
4035
|
-
fieldName: "
|
|
4035
|
+
fieldName: "tableKey";
|
|
4036
4036
|
};
|
|
4037
4037
|
};
|
|
4038
|
-
|
|
4038
|
+
indexName: ConvexTextBuilderInitial<""> & {
|
|
4039
4039
|
_: {
|
|
4040
4040
|
notNull: true;
|
|
4041
4041
|
};
|
|
@@ -4045,10 +4045,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4045
4045
|
};
|
|
4046
4046
|
} & {
|
|
4047
4047
|
_: {
|
|
4048
|
-
fieldName: "
|
|
4048
|
+
fieldName: "indexName";
|
|
4049
4049
|
};
|
|
4050
4050
|
};
|
|
4051
|
-
|
|
4051
|
+
updatedAt: ConvexNumberBuilderInitial<""> & {
|
|
4052
4052
|
_: {
|
|
4053
4053
|
notNull: true;
|
|
4054
4054
|
};
|
|
@@ -4058,10 +4058,10 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4058
4058
|
};
|
|
4059
4059
|
} & {
|
|
4060
4060
|
_: {
|
|
4061
|
-
fieldName: "
|
|
4061
|
+
fieldName: "updatedAt";
|
|
4062
4062
|
};
|
|
4063
4063
|
};
|
|
4064
|
-
|
|
4064
|
+
keyHash: ConvexTextBuilderInitial<""> & {
|
|
4065
4065
|
_: {
|
|
4066
4066
|
notNull: true;
|
|
4067
4067
|
};
|
|
@@ -4071,7 +4071,7 @@ declare const BUILTIN_SCHEMA_EXTENSIONS: readonly [SchemaExtension<{
|
|
|
4071
4071
|
};
|
|
4072
4072
|
} & {
|
|
4073
4073
|
_: {
|
|
4074
|
-
fieldName: "
|
|
4074
|
+
fieldName: "keyHash";
|
|
4075
4075
|
};
|
|
4076
4076
|
};
|
|
4077
4077
|
fieldName: ConvexTextBuilderInitial<""> & {
|