better-convex 0.9.2 → 0.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aggregate/index.d.ts +1 -4
- package/dist/auth/index.d.ts +0 -1
- package/dist/auth/nextjs/index.d.ts +0 -1
- package/dist/crpc/index.d.ts +34 -5
- package/dist/crpc/index.js +142 -1
- package/dist/orm/index.d.ts +1 -1
- package/dist/orm/index.js +8 -1
- package/dist/plugins/index.d.ts +4 -4
- package/dist/plugins/ratelimit/index.d.ts +1 -4
- package/dist/react/index.d.ts +48 -59
- package/dist/react/index.js +119 -101
- package/dist/rsc/index.d.ts +99 -22
- package/dist/rsc/index.js +1 -1
- package/dist/server/index.d.ts +0 -1
- package/dist/solid/index.d.ts +1221 -0
- package/dist/solid/index.js +2930 -0
- package/dist/types-7bF_8IjP.d.ts +213 -0
- package/dist/watcher.mjs +46 -8
- package/dist/{where-clause-compiler-DjFwXrQn.d.ts → where-clause-compiler-UavDdMUX.d.ts} +1 -4
- package/package.json +15 -1
- package/dist/types-f53SgpBL.d.ts +0 -221
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import { Jn as ConvexTextBuilderInitial, Ot as ConvexCustomBuilderInitial, in as ConvexTableWithColumns, vt as ConvexNumberBuilderInitial, xt as ConvexIdBuilderInitial } from "../where-clause-compiler-DjFwXrQn.js";
|
|
3
|
-
import "../query-context-ji7By8u0.js";
|
|
4
|
-
import "../orm/index.js";
|
|
1
|
+
import { Dt as ConvexCustomBuilderInitial, _t as ConvexNumberBuilderInitial, bt as ConvexIdBuilderInitial, qn as ConvexTextBuilderInitial, rn as ConvexTableWithColumns } from "../where-clause-compiler-UavDdMUX.js";
|
|
5
2
|
import * as convex_values0 from "convex/values";
|
|
6
3
|
import { GenericId, Infer, Value } from "convex/values";
|
|
7
4
|
import { DocumentByName, GenericDataModel, GenericDatabaseReader, GenericDatabaseWriter, TableNamesInDataModel } from "convex/server";
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "../validators-BcQFm1oY.js";
|
|
2
1
|
import { a as QueryCtxWithPreferredOrmQueryTable, n as LookupByIdResultByCtx, t as DocByCtx } from "../query-context-ji7By8u0.js";
|
|
3
2
|
import { t as GetAuth } from "../types-CM67ko7K.js";
|
|
4
3
|
import { A as GenericCtx } from "../procedure-caller-kZJx_hmP.js";
|
package/dist/crpc/index.d.ts
CHANGED
|
@@ -1,7 +1,36 @@
|
|
|
1
1
|
import { $ as identityTransformer, G as DataTransformerOptions, H as CombinedDataTransformer, J as dateWireCodec, K as WireCodec, Q as getTransformer, U as DATE_CODEC_TAG, W as DataTransformer, X as defaultCRPCTransformer, Y as decodeWire, Z as encodeWire, a as HttpProcedureCall, c as InferHttpInput, i as HttpErrorCode, l as InferHttpOutput, n as HttpClientError, o as HttpRouteInfo, q as createTaggedTransformer, r as HttpClientFromRouter, s as HttpRouteMap, t as HttpClient, u as isHttpClientError } from "../http-types-BK7FuIcR.js";
|
|
2
|
-
import { C as
|
|
2
|
+
import { A as HttpInputArgs, C as ReservedMutationOptions, D as VanillaMutation, E as VanillaAction, F as replaceUrlParam, M as RESERVED_KEYS, N as buildSearchParams, O as HttpClientOptions, P as executeHttpRequest, S as ReservedInfiniteQueryOptions, T as StaticQueryOptsParam, _ as IsPaginated, a as BaseInfiniteQueryOptsParam, b as PaginatedFnMeta, c as ConvexMutationKey, d as ConvexQueryMeta, f as EmptyObject, g as InfiniteQueryInput, h as FnMeta, i as BaseConvexQueryOptions, j as HttpProxyBaseOptions, k as HttpFormValue, l as ConvexQueryHookOptions, m as FUNC_REF_SYMBOL, n as BaseConvexActionOptions, o as ConvexActionKey, p as ExtractPaginatedItem, r as BaseConvexInfiniteQueryOptions, s as ConvexInfiniteQueryMeta, t as AuthType, u as ConvexQueryKey, v as Meta, w as ReservedQueryOptions, x as PaginationOpts, y as MutationVariables } from "../types-7bF_8IjP.js";
|
|
3
3
|
import { FunctionArgs, FunctionReference } from "convex/server";
|
|
4
4
|
|
|
5
|
+
//#region src/crpc/auth-error.d.ts
|
|
6
|
+
/**
|
|
7
|
+
* Auth Mutation Error
|
|
8
|
+
*
|
|
9
|
+
* Framework-agnostic error class for Better Auth mutations.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Error thrown when a Better Auth mutation fails.
|
|
13
|
+
* Contains the original error details from Better Auth.
|
|
14
|
+
*/
|
|
15
|
+
declare class AuthMutationError extends Error {
|
|
16
|
+
/** Error code from Better Auth (e.g., 'INVALID_PASSWORD', 'EMAIL_ALREADY_REGISTERED') */
|
|
17
|
+
code?: string;
|
|
18
|
+
/** HTTP status code */
|
|
19
|
+
status: number;
|
|
20
|
+
/** HTTP status text */
|
|
21
|
+
statusText: string;
|
|
22
|
+
constructor(authError: {
|
|
23
|
+
message?: string;
|
|
24
|
+
status: number;
|
|
25
|
+
statusText: string;
|
|
26
|
+
code?: string;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Type guard to check if an error is an AuthMutationError.
|
|
31
|
+
*/
|
|
32
|
+
declare function isAuthMutationError(error: unknown): error is AuthMutationError;
|
|
33
|
+
//#endregion
|
|
5
34
|
//#region src/crpc/error.d.ts
|
|
6
35
|
/**
|
|
7
36
|
* Client error codes (subset of CRPC codes for client-side use)
|
|
@@ -40,7 +69,7 @@ declare const defaultIsUnauthorized: (error: unknown) => boolean;
|
|
|
40
69
|
*/
|
|
41
70
|
declare function convexQuery<T extends FunctionReference<'query'>>(funcRef: T, args?: FunctionArgs<T> | 'skip', meta?: Meta, opts?: {
|
|
42
71
|
skipUnauth?: boolean;
|
|
43
|
-
}):
|
|
72
|
+
}): BaseConvexQueryOptions<T> & {
|
|
44
73
|
meta: ConvexQueryMeta;
|
|
45
74
|
};
|
|
46
75
|
/**
|
|
@@ -62,7 +91,7 @@ declare function convexQuery<T extends FunctionReference<'query'>>(funcRef: T, a
|
|
|
62
91
|
*/
|
|
63
92
|
declare function convexAction<T extends FunctionReference<'action'>>(funcRef: T, args?: FunctionArgs<T> | 'skip', meta?: Meta, opts?: {
|
|
64
93
|
skipUnauth?: boolean;
|
|
65
|
-
}):
|
|
94
|
+
}): BaseConvexActionOptions<T> & {
|
|
66
95
|
meta: ConvexQueryMeta;
|
|
67
96
|
};
|
|
68
97
|
/**
|
|
@@ -71,6 +100,6 @@ declare function convexAction<T extends FunctionReference<'action'>>(funcRef: T,
|
|
|
71
100
|
*
|
|
72
101
|
* Uses flat { cursor, limit } input like tRPC.
|
|
73
102
|
*/
|
|
74
|
-
declare function convexInfiniteQueryOptions<T extends FunctionReference<'query'>>(funcRef: T, args: Record<string, unknown> | 'skip', opts?:
|
|
103
|
+
declare function convexInfiniteQueryOptions<T extends FunctionReference<'query'>>(funcRef: T, args: Record<string, unknown> | 'skip', opts?: BaseInfiniteQueryOptsParam<T> & Record<string, unknown>, meta?: Meta): BaseConvexInfiniteQueryOptions<T> & Record<string, unknown>;
|
|
75
104
|
//#endregion
|
|
76
|
-
export { AuthType,
|
|
105
|
+
export { AuthMutationError, AuthType, BaseConvexActionOptions, BaseConvexInfiniteQueryOptions, BaseConvexQueryOptions, BaseInfiniteQueryOptsParam, CRPCClientError, CombinedDataTransformer, ConvexActionKey, ConvexInfiniteQueryMeta, ConvexMutationKey, ConvexQueryHookOptions, ConvexQueryKey, ConvexQueryMeta, DATE_CODEC_TAG, DataTransformer, DataTransformerOptions, EmptyObject, ExtractPaginatedItem, FUNC_REF_SYMBOL, FnMeta, HttpClient, HttpClientError, HttpClientFromRouter, HttpClientOptions, HttpErrorCode, HttpFormValue, HttpInputArgs, HttpProcedureCall, HttpProxyBaseOptions, HttpRouteInfo, HttpRouteMap, InferHttpInput, InferHttpOutput, InfiniteQueryInput, IsPaginated, Meta, MutationVariables, PaginatedFnMeta, PaginationOpts, RESERVED_KEYS, ReservedInfiniteQueryOptions, ReservedMutationOptions, ReservedQueryOptions, StaticQueryOptsParam, VanillaAction, VanillaMutation, WireCodec, buildSearchParams, convexAction, convexInfiniteQueryOptions, convexQuery, createTaggedTransformer, dateWireCodec, decodeWire, defaultCRPCTransformer, defaultIsUnauthorized, encodeWire, executeHttpRequest, getTransformer, identityTransformer, isAuthMutationError, isCRPCClientError, isCRPCError, isCRPCErrorCode, isHttpClientError, replaceUrlParam };
|
package/dist/crpc/index.js
CHANGED
|
@@ -2,6 +2,39 @@ import { a as isCRPCErrorCode, i as isCRPCError, n as defaultIsUnauthorized, r a
|
|
|
2
2
|
import { a as defaultCRPCTransformer, c as identityTransformer, i as decodeWire, n as createTaggedTransformer, o as encodeWire, r as dateWireCodec, s as getTransformer, t as DATE_CODEC_TAG } from "../transformer-ogg-4d78.js";
|
|
3
3
|
import { n as convexInfiniteQueryOptions, r as convexQuery, t as convexAction } from "../query-options-CSCmKYdJ.js";
|
|
4
4
|
|
|
5
|
+
//#region src/crpc/auth-error.ts
|
|
6
|
+
/**
|
|
7
|
+
* Auth Mutation Error
|
|
8
|
+
*
|
|
9
|
+
* Framework-agnostic error class for Better Auth mutations.
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Error thrown when a Better Auth mutation fails.
|
|
13
|
+
* Contains the original error details from Better Auth.
|
|
14
|
+
*/
|
|
15
|
+
var AuthMutationError = class extends Error {
|
|
16
|
+
/** Error code from Better Auth (e.g., 'INVALID_PASSWORD', 'EMAIL_ALREADY_REGISTERED') */
|
|
17
|
+
code;
|
|
18
|
+
/** HTTP status code */
|
|
19
|
+
status;
|
|
20
|
+
/** HTTP status text */
|
|
21
|
+
statusText;
|
|
22
|
+
constructor(authError) {
|
|
23
|
+
super(authError.message || authError.statusText);
|
|
24
|
+
this.name = "AuthMutationError";
|
|
25
|
+
this.code = authError.code;
|
|
26
|
+
this.status = authError.status;
|
|
27
|
+
this.statusText = authError.statusText;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Type guard to check if an error is an AuthMutationError.
|
|
32
|
+
*/
|
|
33
|
+
function isAuthMutationError(error) {
|
|
34
|
+
return error instanceof AuthMutationError;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
//#endregion
|
|
5
38
|
//#region src/crpc/http-types.ts
|
|
6
39
|
/** HTTP client error */
|
|
7
40
|
var HttpClientError = class extends Error {
|
|
@@ -19,10 +52,118 @@ var HttpClientError = class extends Error {
|
|
|
19
52
|
/** Type guard for HttpClientError */
|
|
20
53
|
const isHttpClientError = (error) => error instanceof HttpClientError;
|
|
21
54
|
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/crpc/http-client.ts
|
|
57
|
+
/**
|
|
58
|
+
* HTTP Client Helpers
|
|
59
|
+
*
|
|
60
|
+
* Framework-agnostic utilities for executing HTTP requests
|
|
61
|
+
* against Convex HTTP endpoints.
|
|
62
|
+
*/
|
|
63
|
+
/** Reserved keys that are not part of JSON body */
|
|
64
|
+
const RESERVED_KEYS = new Set([
|
|
65
|
+
"params",
|
|
66
|
+
"searchParams",
|
|
67
|
+
"form",
|
|
68
|
+
"fetch",
|
|
69
|
+
"init",
|
|
70
|
+
"headers"
|
|
71
|
+
]);
|
|
72
|
+
/**
|
|
73
|
+
* Replace URL path parameters with actual values.
|
|
74
|
+
* e.g., '/users/:id' with { id: '123' } -> '/users/123'
|
|
75
|
+
*/
|
|
76
|
+
function replaceUrlParam(url, params) {
|
|
77
|
+
return url.replace(/:(\w+)/g, (_, key) => {
|
|
78
|
+
const value = params[key];
|
|
79
|
+
return value !== void 0 ? encodeURIComponent(value) : `:${key}`;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Build URLSearchParams from query object.
|
|
84
|
+
* Handles array values as multiple params with same key (like Hono).
|
|
85
|
+
*/
|
|
86
|
+
function buildSearchParams(query) {
|
|
87
|
+
const params = new URLSearchParams();
|
|
88
|
+
for (const [key, value] of Object.entries(query)) if (Array.isArray(value)) for (const v of value) params.append(key, v);
|
|
89
|
+
else if (value !== void 0 && value !== null) params.append(key, value);
|
|
90
|
+
return params;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Hono-style HTTP request executor.
|
|
94
|
+
* Processes args in the same way as Hono's ClientRequestImpl.fetch().
|
|
95
|
+
*/
|
|
96
|
+
async function executeHttpRequest(opts) {
|
|
97
|
+
const { method, path } = opts.route;
|
|
98
|
+
const args = opts.args ?? {};
|
|
99
|
+
let rBody;
|
|
100
|
+
let cType;
|
|
101
|
+
if (args.form) {
|
|
102
|
+
const form = new FormData();
|
|
103
|
+
for (const [k, v] of Object.entries(args.form)) if (Array.isArray(v)) for (const v2 of v) form.append(k, v2);
|
|
104
|
+
else form.append(k, v);
|
|
105
|
+
rBody = form;
|
|
106
|
+
} else {
|
|
107
|
+
const jsonBody = {};
|
|
108
|
+
for (const [key, value] of Object.entries(args)) if (!RESERVED_KEYS.has(key) && value !== void 0) jsonBody[key] = value;
|
|
109
|
+
if (Object.keys(jsonBody).length > 0) {
|
|
110
|
+
rBody = JSON.stringify(opts.transformer.input.serialize(jsonBody));
|
|
111
|
+
cType = "application/json";
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const argsClientOpts = {};
|
|
115
|
+
if (args.fetch) argsClientOpts.fetch = args.fetch;
|
|
116
|
+
if (args.init) argsClientOpts.init = args.init;
|
|
117
|
+
if (args.headers) argsClientOpts.headers = args.headers;
|
|
118
|
+
const mergedClientOpts = {
|
|
119
|
+
...opts.clientOpts,
|
|
120
|
+
...argsClientOpts
|
|
121
|
+
};
|
|
122
|
+
const resolvedBaseHeaders = typeof opts.baseHeaders === "function" ? await opts.baseHeaders() : opts.baseHeaders;
|
|
123
|
+
const headerValues = { ...typeof mergedClientOpts.headers === "function" ? await mergedClientOpts.headers() : mergedClientOpts.headers };
|
|
124
|
+
if (cType) headerValues["Content-Type"] = cType;
|
|
125
|
+
const finalHeaders = {};
|
|
126
|
+
if (resolvedBaseHeaders) {
|
|
127
|
+
for (const [key, value] of Object.entries(resolvedBaseHeaders)) if (value !== void 0) finalHeaders[key] = value;
|
|
128
|
+
}
|
|
129
|
+
Object.assign(finalHeaders, headerValues);
|
|
130
|
+
let url = opts.convexSiteUrl + path;
|
|
131
|
+
if (args.params) url = opts.convexSiteUrl + replaceUrlParam(path, args.params);
|
|
132
|
+
if (args.searchParams) {
|
|
133
|
+
const queryString = buildSearchParams(args.searchParams).toString();
|
|
134
|
+
if (queryString) url = `${url}?${queryString}`;
|
|
135
|
+
}
|
|
136
|
+
const methodUpperCase = method.toUpperCase();
|
|
137
|
+
const setBody = !(methodUpperCase === "GET" || methodUpperCase === "HEAD");
|
|
138
|
+
const response = await (mergedClientOpts.fetch ?? opts.baseFetch ?? globalThis.fetch)(url, {
|
|
139
|
+
body: setBody ? rBody : void 0,
|
|
140
|
+
method: methodUpperCase,
|
|
141
|
+
headers: finalHeaders,
|
|
142
|
+
...mergedClientOpts.init
|
|
143
|
+
});
|
|
144
|
+
if (!response.ok) {
|
|
145
|
+
const errorData = await response.json().catch(() => ({ error: {
|
|
146
|
+
code: "UNKNOWN",
|
|
147
|
+
message: response.statusText
|
|
148
|
+
} }));
|
|
149
|
+
const errorCode = errorData?.error?.code || "UNKNOWN";
|
|
150
|
+
const errorMessage = errorData?.error?.message || response.statusText;
|
|
151
|
+
throw new HttpClientError({
|
|
152
|
+
code: errorCode,
|
|
153
|
+
status: response.status,
|
|
154
|
+
procedureName: opts.procedureName,
|
|
155
|
+
message: errorMessage
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
if (response.headers.get("content-length") === "0" || response.status === 204) return;
|
|
159
|
+
if ((response.headers.get("content-type") || "").includes("application/json")) return opts.transformer.output.deserialize(await response.json());
|
|
160
|
+
return response.text();
|
|
161
|
+
}
|
|
162
|
+
|
|
22
163
|
//#endregion
|
|
23
164
|
//#region src/crpc/types.ts
|
|
24
165
|
/** Symbol key for attaching FunctionReference to options (non-serializable) */
|
|
25
166
|
const FUNC_REF_SYMBOL = Symbol.for("convex.funcRef");
|
|
26
167
|
|
|
27
168
|
//#endregion
|
|
28
|
-
export { CRPCClientError, DATE_CODEC_TAG, FUNC_REF_SYMBOL, HttpClientError, convexAction, convexInfiniteQueryOptions, convexQuery, createTaggedTransformer, dateWireCodec, decodeWire, defaultCRPCTransformer, defaultIsUnauthorized, encodeWire, getTransformer, identityTransformer, isCRPCClientError, isCRPCError, isCRPCErrorCode, isHttpClientError };
|
|
169
|
+
export { AuthMutationError, CRPCClientError, DATE_CODEC_TAG, FUNC_REF_SYMBOL, HttpClientError, RESERVED_KEYS, buildSearchParams, convexAction, convexInfiniteQueryOptions, convexQuery, createTaggedTransformer, dateWireCodec, decodeWire, defaultCRPCTransformer, defaultIsUnauthorized, encodeWire, executeHttpRequest, getTransformer, identityTransformer, isAuthMutationError, isCRPCClientError, isCRPCError, isCRPCErrorCode, isHttpClientError, replaceUrlParam };
|
package/dist/orm/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as pretendRequired, n as deprecated, r as pretend } from "../validators-BcQFm1oY.js";
|
|
2
|
-
import { $ as
|
|
2
|
+
import { $ as DatabaseWithQuery, $n as BuildRelationResult, $r as notInArray, $t as defineRelationsPart, A as MigrationRunArgs, An as aggregateIndex, Ar as FieldReference, At as json, B as MigrationMigrateOne, Bn as ConvexUniqueConstraintBuilder, Br as gt, Bt as bigint, C as OrmBeforeResult, Cn as ConvexRankIndexBuilderOn, Cr as ReturningSelection, Ct as ConvexDateBuilderInitial, D as OrmTriggers, Dn as ConvexVectorIndexBuilder, Dr as unsetToken, Dt as ConvexCustomBuilderInitial, E as OrmTriggerContext, En as ConvexSearchIndexConfig, Er as VectorSearchProvider, Et as ConvexCustomBuilder, F as MigrationDirection, Fn as vectorIndex, Fr as between, Ft as ConvexBooleanBuilder, G as MigrationStep, Gn as unique, Gr as isNotNull, Gt as ManyConfig, H as MigrationRunStatus, Hn as ConvexUniqueConstraintConfig, Hr as ilike, Ht as CountBackfillKickoffArgs, I as MigrationDoc, In as ConvexCheckBuilder, Ir as contains, It as ConvexBooleanBuilderInitial, J as buildMigrationPlan, Jn as text, Jr as lt, Jt as RelationsBuilderColumnBase, K as MigrationTableName, Kn as ConvexTextBuilder, Kr as isNull, Kt as OneConfig, L as MigrationDocContext, Ln as ConvexCheckConfig, Lr as endsWith, Lt as boolean, M as MigrationStatusArgs, Mn as rankIndex, Mr as LogicalExpression, Mt as ConvexBytesBuilder, N as MigrationAppliedState, Nn as searchIndex, Nr as UnaryExpression, Nt as ConvexBytesBuilderInitial, O as defineTriggers, On as ConvexVectorIndexBuilderOn, Or as BinaryExpression, Ot as arrayOf, P as MigrationDefinition, Pn as uniqueIndex, Pr as and, Pt as bytes, Q as DatabaseWithMutations, Qn as BuildQueryResult, Qr as notBetween, Qt as defineRelations, R as MigrationDriftIssue, Rn as ConvexForeignKeyBuilder, Rr as eq, Rt as ConvexBigIntBuilder, S as scheduledDeleteFactory, Sn as ConvexRankIndexBuilder, Sr as ReturningResult, St as ConvexDateBuilder, T as OrmTriggerChange, Tn as ConvexSearchIndexBuilderOn, Tr as VectorQueryConfig, Tt as date, U as MigrationSet, Un as check, Ur as inArray, Ut as CountBackfillStatusArgs, V as MigrationPlan, Vn as ConvexUniqueConstraintBuilderOn, Vr as gte, Vt as CountBackfillChunkArgs, W as MigrationStateMap, Wn as foreignKey, Wr as isFieldReference, Wt as ExtractTablesWithRelations, X as defineMigrationSet, Xn as AggregateFieldValue, Xr as ne, Xt as TableRelationalConfig, Y as defineMigration, Yn as AggregateConfig, Yr as lte, Yt as RelationsBuilderColumnConfig, Z as detectMigrationDrift, Zn as AggregateResult, Zr as not, Zt as TablesRelationalConfig, _ as OrmWriterCtx, _i as IsPrimaryKey, _n as rlsRole, _r as OrderByClause, _t as ConvexNumberBuilderInitial, a as TableConfigResult, ai as OrmSchemaPluginTables, an as OrmLifecycleChange, ar as InferInsertModel, at as extractRelationsConfig, b as scheduledMutationBatchFactory, bn as ConvexIndexBuilder, br as PredicateWhereIndexConfig, bt as ConvexIdBuilderInitial, c as OrmNotFoundError, ci as AnyColumn, cn as convexTable, cr as InsertValue, ct as vector, d as GenericOrmCtx, di as ColumnBuilderRuntimeConfig, dn as RlsPolicy, dr as MutationExecutionMode, dt as ConvexTimestampMode, ei as or, en as ConvexDeletionBuilder, er as CountConfig, et as OrmReader, f as OrmApiResult, fi as ColumnBuilderTypeConfig, fn as RlsPolicyConfig, fr as MutationPaginateConfig, ft as timestamp, g as OrmReaderCtx, gi as HasDefault, gn as RlsRoleConfig, gr as MutationRunMode, gt as ConvexNumberBuilder, h as OrmFunctions, hi as DrizzleEntity, hn as RlsRole, hr as MutationReturning, ht as textEnum, i as desc, ii as OrmSchemaPlugin, in as DiscriminatorBuilderConfig, ir as GetColumnData, it as EdgeMetadata, j as MigrationRunChunkArgs, jn as index, jr as FilterExpression, jt as objectOf, k as MigrationCancelArgs, kn as ConvexVectorIndexConfig, kr as ExpressionVisitor, kt as custom, l as CreateOrmOptions, li as ColumnBuilder, ln as deletion, lr as MutationExecuteConfig, lt as ConvexTimestampBuilder, m as OrmClientWithApi, mi as ColumnDataType, mn as rlsPolicy, mr as MutationResult, mt as ConvexTextEnumBuilderInitial, n as defineSchema, ni as Brand, nn as ConvexTable, nr as DBQueryConfig, nt as RlsContext, o as getTableColumns, oi as TableName, on as OrmLifecycleOperation, or as InferModelFromColumns, ot as ConvexVectorBuilder, p as OrmClientBase, pi as ColumnBuilderWithTableName, pn as RlsPolicyToOption, pr as MutationPaginatedResult, pt as ConvexTextEnumBuilder, q as MigrationWriteMode, qn as ConvexTextBuilderInitial, qr as like, qt as RelationsBuilder, r as asc, ri as Columns, rr as FilterOperators, rt as RlsMode, s as getTableConfig, si as SystemFields, sn as TableConfig, sr as InferSelectModel, st as ConvexVectorBuilderInitial, t as WhereClauseResult, ti as startsWith, tn as ConvexDeletionConfig, tr as CountResult, tt as OrmWriter, u as GenericOrm, ui as ColumnBuilderBaseConfig, un as discriminator, ur as MutationExecuteResult, ut as ConvexTimestampBuilderInitial, v as createOrm, vi as IsUnique, vn as ConvexAggregateIndexBuilder, vr as OrderDirection, vt as integer, w as OrmTableTriggers, wn as ConvexSearchIndexBuilder, wr as UpdateSet, wt as ConvexDateMode, x as ScheduledDeleteArgs, xn as ConvexIndexBuilderOn, xr as ReturningAll, xt as id, y as ScheduledMutationBatchArgs, yi as NotNull, yn as ConvexAggregateIndexBuilderOn, yr as PaginatedResult, yt as ConvexIdBuilder, z as MigrationManifestEntry, zn as ConvexForeignKeyConfig, zr as fieldRef, zt as ConvexBigIntBuilderInitial } from "../where-clause-compiler-UavDdMUX.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-ji7By8u0.js";
|
|
4
4
|
import { DefineSchemaOptions, GenericSchema, SchemaDefinition } from "convex/server";
|
|
5
5
|
export { type AggregateConfig, type AggregateFieldValue, type AggregateResult, type AnyColumn, type BinaryExpression, Brand, type BuildQueryResult, type BuildRelationResult, type ColumnBuilder, type ColumnBuilderBaseConfig, type ColumnBuilderRuntimeConfig, type ColumnBuilderTypeConfig, type ColumnBuilderWithTableName, type ColumnDataType, Columns, type ConvexAggregateIndexBuilder, type ConvexAggregateIndexBuilderOn, type ConvexBigIntBuilder, type ConvexBigIntBuilderInitial, type ConvexBooleanBuilder, type ConvexBooleanBuilderInitial, type ConvexBytesBuilder, type ConvexBytesBuilderInitial, type ConvexCheckBuilder, type ConvexCheckConfig, type ConvexCustomBuilder, type ConvexCustomBuilderInitial, type ConvexDateBuilder, type ConvexDateBuilderInitial, type ConvexDateMode, type ConvexDeletionBuilder, type ConvexDeletionConfig, type ConvexForeignKeyBuilder, type ConvexForeignKeyConfig, type ConvexIdBuilder, type ConvexIdBuilderInitial, type ConvexIndexBuilder, type ConvexIndexBuilderOn, type ConvexNumberBuilder, type ConvexNumberBuilderInitial, type ConvexRankIndexBuilder, type ConvexRankIndexBuilderOn, type ConvexSearchIndexBuilder, type ConvexSearchIndexBuilderOn, type ConvexSearchIndexConfig, type ConvexTable, type ConvexTextBuilder, type ConvexTextBuilderInitial, type ConvexTextEnumBuilder, type ConvexTextEnumBuilderInitial, type ConvexTimestampBuilder, type ConvexTimestampBuilderInitial, type ConvexTimestampMode, type ConvexUniqueConstraintBuilder, type ConvexUniqueConstraintBuilderOn, type ConvexUniqueConstraintConfig, type ConvexVectorBuilder, type ConvexVectorBuilderInitial, type ConvexVectorIndexBuilder, type ConvexVectorIndexBuilderOn, type ConvexVectorIndexConfig, type CountBackfillChunkArgs, type CountBackfillKickoffArgs, type CountBackfillStatusArgs, type CountConfig, type CountResult, type CreateOrmOptions, type DBQueryConfig, type DatabaseWithMutations, type DatabaseWithQuery, type DefineSchemaOptions, type DiscriminatorBuilderConfig, type DocByCtx, type DrizzleEntity, type EdgeMetadata, type ExpressionVisitor, type ExtractTablesWithRelations, type FieldReference, type FilterExpression, type FilterOperators, type GenericOrm, type GenericOrmCtx, type GenericSchema, type GetColumnData, type HasDefault, type InferInsertModel, type InferModelFromColumns, type InferSelectModel, type InsertValue, type IsPrimaryKey, type IsUnique, type LogicalExpression, type LookupByIdResultByCtx, type ManyConfig, type MigrationAppliedState, type MigrationCancelArgs, type MigrationDefinition, type MigrationDirection, type MigrationDoc, type MigrationDocContext, type MigrationDriftIssue, type MigrationManifestEntry, type MigrationMigrateOne, type MigrationPlan, type MigrationRunArgs, type MigrationRunChunkArgs, type MigrationRunStatus, type MigrationSet, type MigrationStateMap, type MigrationStatusArgs, type MigrationStep, type MigrationTableName, type MigrationWriteMode, type MutationExecuteConfig, type MutationExecuteResult, type MutationExecutionMode, type MutationPaginateConfig, type MutationPaginatedResult, type MutationResult, type MutationReturning, type MutationRunMode, type NotNull, type OneConfig, type OrderByClause, type OrderDirection, type OrmApiResult, type OrmBeforeResult, type OrmClientBase, type OrmClientWithApi, type OrmFunctions, type OrmLifecycleChange, type OrmLifecycleOperation, OrmNotFoundError, type OrmReader, type OrmReaderCtx, type OrmSchemaPlugin, OrmSchemaPluginTables, type OrmTableTriggers, type OrmTriggerChange, type OrmTriggerContext, type OrmTriggers, type OrmWriter, type OrmWriterCtx, type PaginatedResult, type PredicateWhereIndexConfig, type QueryCtxWithOptionalOrmQueryTable, type QueryCtxWithOrmQueryTable, type QueryCtxWithPreferredOrmQueryTable, type RelationsBuilder, type RelationsBuilderColumnBase, type RelationsBuilderColumnConfig, type ReturningAll, type ReturningResult, type ReturningSelection, type RlsContext, type RlsMode, RlsPolicy, type RlsPolicyConfig, type RlsPolicyToOption, RlsRole, type RlsRoleConfig, type ScheduledDeleteArgs, type ScheduledMutationBatchArgs, type SchemaDefinition, type SystemFields, type TableConfig, type TableConfigResult, TableName, type TableRelationalConfig, type TablesRelationalConfig, type UnaryExpression, type UpdateSet, type VectorQueryConfig, type VectorSearchProvider, type WhereClauseResult, aggregateIndex, and, arrayOf, asc, between, bigint, boolean, buildMigrationPlan, bytes, check, contains, convexTable, createOrm, custom, date, defineMigration, defineMigrationSet, defineRelations, defineRelationsPart, defineSchema, defineTriggers, deletion, deprecated, desc, detectMigrationDrift, discriminator, endsWith, eq, extractRelationsConfig, fieldRef, foreignKey, getByIdWithOrmQueryFallback, getTableColumns, getTableConfig, gt, gte, id, ilike, inArray, index, integer, isFieldReference, isNotNull, isNull, json, like, lt, lte, ne, not, notBetween, notInArray, objectOf, or, pretend, pretendRequired, rankIndex, rlsPolicy, rlsRole, scheduledDeleteFactory, scheduledMutationBatchFactory, searchIndex, startsWith, text, textEnum, timestamp, unique, uniqueIndex, unsetToken, vector, vectorIndex };
|
package/dist/orm/index.js
CHANGED
|
@@ -2075,6 +2075,12 @@ function findRelationIndex(table, columns, relationName, targetTableName, strict
|
|
|
2075
2075
|
const PUBLIC_CREATED_AT_FIELD = "createdAt";
|
|
2076
2076
|
const INTERNAL_CREATION_TIME_FIELD = "_creationTime";
|
|
2077
2077
|
const CREATED_AT_MIGRATION_MESSAGE = "`_creationTime` is no longer public. Use `createdAt` instead.";
|
|
2078
|
+
const hasUserCreatedAtColumn = (table) => {
|
|
2079
|
+
if (!table || typeof table !== "object") return false;
|
|
2080
|
+
const columns = table[Columns];
|
|
2081
|
+
if (!columns || typeof columns !== "object") return false;
|
|
2082
|
+
return Object.hasOwn(columns, PUBLIC_CREATED_AT_FIELD);
|
|
2083
|
+
};
|
|
2078
2084
|
const usesSystemCreatedAtAlias = (_table) => true;
|
|
2079
2085
|
|
|
2080
2086
|
//#endregion
|
|
@@ -2176,10 +2182,11 @@ const normalizePublicSystemFields = (value, options) => {
|
|
|
2176
2182
|
};
|
|
2177
2183
|
const normalizeDateFieldsForWrite = (table, value) => {
|
|
2178
2184
|
const useSystemCreatedAt = usesSystemCreatedAtAlias(table);
|
|
2185
|
+
const hasUserCreatedAt = hasUserCreatedAtColumn(table);
|
|
2179
2186
|
const temporalColumns = getTemporalColumnDescriptors(table);
|
|
2180
2187
|
const result = { ...value };
|
|
2181
2188
|
if (Object.hasOwn(result, INTERNAL_CREATION_TIME_FIELD)) throw new Error(CREATED_AT_MIGRATION_MESSAGE);
|
|
2182
|
-
if (useSystemCreatedAt && Object.hasOwn(result, PUBLIC_CREATED_AT_FIELD)) delete result[PUBLIC_CREATED_AT_FIELD];
|
|
2189
|
+
if (useSystemCreatedAt && !hasUserCreatedAt && Object.hasOwn(result, PUBLIC_CREATED_AT_FIELD)) delete result[PUBLIC_CREATED_AT_FIELD];
|
|
2183
2190
|
for (const [name, descriptor] of temporalColumns.entries()) {
|
|
2184
2191
|
if (!Object.hasOwn(result, name)) continue;
|
|
2185
2192
|
result[name] = normalizeTemporalWriteValue(descriptor, result[name]);
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import "../
|
|
2
|
-
import { ai as OrmSchemaPlugin, k as migrationPlugin } from "../where-clause-compiler-DjFwXrQn.js";
|
|
3
|
-
import "../query-context-ji7By8u0.js";
|
|
4
|
-
import "../orm/index.js";
|
|
1
|
+
import { ii as OrmSchemaPlugin } from "../where-clause-compiler-UavDdMUX.js";
|
|
5
2
|
|
|
3
|
+
//#region src/orm/migrations/schema.d.ts
|
|
4
|
+
declare function migrationPlugin(): OrmSchemaPlugin;
|
|
5
|
+
//#endregion
|
|
6
6
|
//#region src/orm/aggregate-index/schema.d.ts
|
|
7
7
|
declare function aggregatePlugin(): OrmSchemaPlugin;
|
|
8
8
|
//#endregion
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import "../../
|
|
2
|
-
import { ai as OrmSchemaPlugin } from "../../where-clause-compiler-DjFwXrQn.js";
|
|
3
|
-
import "../../query-context-ji7By8u0.js";
|
|
4
|
-
import "../../orm/index.js";
|
|
1
|
+
import { ii as OrmSchemaPlugin } from "../../where-clause-compiler-UavDdMUX.js";
|
|
5
2
|
import * as convex_server0 from "convex/server";
|
|
6
3
|
|
|
7
4
|
//#region src/plugins/ratelimit/duration.d.ts
|
package/dist/react/index.d.ts
CHANGED
|
@@ -10,7 +10,12 @@ import { ConvexHttpClient } from "convex/browser";
|
|
|
10
10
|
import * as jotai_vanilla0 from "jotai/vanilla";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
|
|
13
|
-
//#region src/
|
|
13
|
+
//#region src/crpc/auth-error.d.ts
|
|
14
|
+
/**
|
|
15
|
+
* Auth Mutation Error
|
|
16
|
+
*
|
|
17
|
+
* Framework-agnostic error class for Better Auth mutations.
|
|
18
|
+
*/
|
|
14
19
|
/**
|
|
15
20
|
* Error thrown when a Better Auth mutation fails.
|
|
16
21
|
* Contains the original error details from Better Auth.
|
|
@@ -33,6 +38,8 @@ declare class AuthMutationError extends Error {
|
|
|
33
38
|
* Type guard to check if an error is an AuthMutationError.
|
|
34
39
|
*/
|
|
35
40
|
declare function isAuthMutationError(error: unknown): error is AuthMutationError;
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region src/react/auth-mutations.d.ts
|
|
36
43
|
type MutationOptionsHook<TData, TVariables = void> = (options?: Omit<UseMutationOptions<TData, DefaultError, TVariables>, 'mutationFn'>) => UseMutationOptions<TData, DefaultError, TVariables>;
|
|
37
44
|
type AnyFn = (...args: any[]) => Promise<any>;
|
|
38
45
|
type AuthClient = {
|
|
@@ -534,6 +541,8 @@ declare const FUNC_REF_SYMBOL: unique symbol;
|
|
|
534
541
|
type ReservedQueryOptions$2 = 'queryKey' | 'queryFn' | 'staleTime';
|
|
535
542
|
/** Options controlled by mutation factories */
|
|
536
543
|
type ReservedMutationOptions$2 = 'mutationFn';
|
|
544
|
+
/** Reserved options controlled by infinite query factories */
|
|
545
|
+
type ReservedInfiniteQueryOptions = 'queryKey' | 'queryFn' | 'staleTime' | 'refetchInterval' | 'refetchOnMount' | 'refetchOnReconnect' | 'refetchOnWindowFocus' | 'persister' | 'placeholderData';
|
|
537
546
|
/** Metadata for a single Convex function */
|
|
538
547
|
type FnMeta$1 = {
|
|
539
548
|
auth?: 'required' | 'optional';
|
|
@@ -569,10 +578,6 @@ type ConvexQueryMeta = {
|
|
|
569
578
|
skipUnauth?: boolean; /** Whether to create WebSocket subscription (default: true) */
|
|
570
579
|
subscribe?: boolean;
|
|
571
580
|
};
|
|
572
|
-
/** Options returned by `convexQuery` factory */
|
|
573
|
-
type ConvexQueryOptions<T extends FunctionReference<'query'>> = Pick<UseQueryOptions<FunctionReturnType<T>, Error, FunctionReturnType<T>, ConvexQueryKey<T>>, 'queryKey' | 'staleTime' | 'enabled'>;
|
|
574
|
-
/** Options returned by `convexAction` factory */
|
|
575
|
-
type ConvexActionOptions<T extends FunctionReference<'action'>> = Pick<UseQueryOptions<FunctionReturnType<T>, Error, FunctionReturnType<T>, ConvexActionKey<T>>, 'queryKey' | 'staleTime' | 'enabled'>;
|
|
576
581
|
/** Hook options for Convex queries */
|
|
577
582
|
type ConvexQueryHookOptions = {
|
|
578
583
|
/** Skip query silently when unauthenticated (default: false, calls onQueryUnauthorized) */skipUnauth?: boolean; /** Set to false to fetch once without subscribing (default: true) */
|
|
@@ -584,7 +589,36 @@ type InfiniteQueryInput<TInput> = Omit<TInput, 'cursor' | 'limit'>;
|
|
|
584
589
|
type ExtractPaginatedItem<TOutput> = TOutput extends {
|
|
585
590
|
page: (infer T)[];
|
|
586
591
|
} ? T : never;
|
|
592
|
+
/** Metadata for infinite query (extends ConvexQueryMeta) */
|
|
593
|
+
type ConvexInfiniteQueryMeta = ConvexQueryMeta & {
|
|
594
|
+
/** The query function name (serializable for RSC) */queryName: string; /** Query args without cursor/limit (user's filter args only) */
|
|
595
|
+
args: Record<string, unknown>; /** Items per page (optional - server uses .paginated() default) */
|
|
596
|
+
limit?: number;
|
|
597
|
+
};
|
|
587
598
|
type EmptyObject = Record<string, never>;
|
|
599
|
+
/** Static query options parameter type (non-hook, for event handlers) */
|
|
600
|
+
type StaticQueryOptsParam = {
|
|
601
|
+
skipUnauth?: boolean;
|
|
602
|
+
};
|
|
603
|
+
/** Check if a type has cursor key (pagination detection) */
|
|
604
|
+
type IsPaginated<T> = 'cursor' extends keyof T ? true : false;
|
|
605
|
+
/** Mutation variables type - undefined when no args required (allows mutateAsync() without args) */
|
|
606
|
+
type MutationVariables<T extends FunctionReference<'mutation' | 'action'>> = keyof FunctionArgs<T> extends never ? void : EmptyObject extends FunctionArgs<T> ? FunctionArgs<T> | undefined : FunctionArgs<T>;
|
|
607
|
+
/** Vanilla mutation - direct .mutate() call without TanStack Query */
|
|
608
|
+
type VanillaMutation<T extends FunctionReference<'mutation'>> = {
|
|
609
|
+
mutate: keyof FunctionArgs<T> extends never ? (args?: EmptyObject) => Promise<FunctionReturnType<T>> : EmptyObject extends FunctionArgs<T> ? (args?: FunctionArgs<T>) => Promise<FunctionReturnType<T>> : (args: FunctionArgs<T>) => Promise<FunctionReturnType<T>>;
|
|
610
|
+
};
|
|
611
|
+
/** Vanilla action - both .query() and .mutate() for direct calls */
|
|
612
|
+
type VanillaAction<T extends FunctionReference<'action'>> = {
|
|
613
|
+
query: keyof FunctionArgs<T> extends never ? (args?: EmptyObject) => Promise<FunctionReturnType<T>> : EmptyObject extends FunctionArgs<T> ? (args?: FunctionArgs<T>) => Promise<FunctionReturnType<T>> : (args: FunctionArgs<T>) => Promise<FunctionReturnType<T>>;
|
|
614
|
+
mutate: keyof FunctionArgs<T> extends never ? (args?: EmptyObject) => Promise<FunctionReturnType<T>> : EmptyObject extends FunctionArgs<T> ? (args?: FunctionArgs<T>) => Promise<FunctionReturnType<T>> : (args: FunctionArgs<T>) => Promise<FunctionReturnType<T>>;
|
|
615
|
+
};
|
|
616
|
+
//#endregion
|
|
617
|
+
//#region src/react/crpc-types.d.ts
|
|
618
|
+
/** Options returned by `convexQuery` factory */
|
|
619
|
+
type ConvexQueryOptions<T extends FunctionReference<'query'>> = Pick<UseQueryOptions<FunctionReturnType<T>, Error, FunctionReturnType<T>, ConvexQueryKey<T>>, 'queryKey' | 'staleTime' | 'enabled'>;
|
|
620
|
+
/** Options returned by `convexAction` factory */
|
|
621
|
+
type ConvexActionOptions<T extends FunctionReference<'action'>> = Pick<UseQueryOptions<FunctionReturnType<T>, Error, FunctionReturnType<T>, ConvexActionKey<T>>, 'queryKey' | 'staleTime' | 'enabled'>;
|
|
588
622
|
/** Query options parameter type */
|
|
589
623
|
type QueryOptsParam<T extends FunctionReference<'query'>> = Simplify<ConvexQueryHookOptions & DistributiveOmit<UseQueryOptions<FunctionReturnType<T>, DefaultError>, ReservedQueryOptions$2>>;
|
|
590
624
|
/** Query options return type */
|
|
@@ -600,10 +634,6 @@ type ActionQueryOptsReturn<T extends FunctionReference<'action'>> = ConvexAction
|
|
|
600
634
|
* Args are optional when the function has no required parameters.
|
|
601
635
|
* Supports skipToken for type-safe conditional queries.
|
|
602
636
|
*/
|
|
603
|
-
/** Static query options parameter type (non-hook, for event handlers) */
|
|
604
|
-
type StaticQueryOptsParam = {
|
|
605
|
-
skipUnauth?: boolean;
|
|
606
|
-
};
|
|
607
637
|
type DecorateQuery<T extends FunctionReference<'query'>> = {
|
|
608
638
|
queryOptions: keyof FunctionArgs<T> extends never ? (args?: EmptyObject | SkipToken, opts?: QueryOptsParam<T>) => QueryOptsReturn<T> : EmptyObject extends FunctionArgs<T> ? (args?: FunctionArgs<T> | SkipToken, opts?: QueryOptsParam<T>) => QueryOptsReturn<T> : (args: FunctionArgs<T> | SkipToken, opts?: QueryOptsParam<T>) => QueryOptsReturn<T>; /** Static (non-hook) query options for event handlers and prefetching */
|
|
609
639
|
staticQueryOptions: keyof FunctionArgs<T> extends never ? (args?: EmptyObject | SkipToken, opts?: StaticQueryOptsParam) => ConvexQueryOptions<T> & {
|
|
@@ -616,20 +646,12 @@ type DecorateQuery<T extends FunctionReference<'query'>> = {
|
|
|
616
646
|
queryKey: (args?: DeepPartial<FunctionArgs<T>>) => ConvexQueryKey<T>; /** Get query filter for QueryClient methods (invalidateQueries, removeQueries, etc.) */
|
|
617
647
|
queryFilter: (args?: DeepPartial<FunctionArgs<T>>, filters?: DistributiveOmit<QueryFilters, 'queryKey'>) => QueryFilters;
|
|
618
648
|
};
|
|
619
|
-
/** Reserved options controlled by infinite query factories */
|
|
620
|
-
type ReservedInfiniteQueryOptions = 'queryKey' | 'queryFn' | 'staleTime' | 'refetchInterval' | 'refetchOnMount' | 'refetchOnReconnect' | 'refetchOnWindowFocus' | 'persister' | 'placeholderData';
|
|
621
649
|
/** Options for infinite query - extends TanStack Query options */
|
|
622
650
|
type InfiniteQueryOptsParam<T extends FunctionReference<'query'> = FunctionReference<'query'>> = {
|
|
623
651
|
/** Items per page. Optional - server uses .paginated() default if not provided. */limit?: number; /** Skip query silently when unauthenticated */
|
|
624
652
|
skipUnauth?: boolean; /** Placeholder data shown while loading (item array, not pagination result) */
|
|
625
653
|
placeholderData?: ExtractPaginatedItem<FunctionReturnType<T>>[];
|
|
626
654
|
} & DistributiveOmit<UseQueryOptions<FunctionReturnType<T>, DefaultError>, ReservedInfiniteQueryOptions>;
|
|
627
|
-
/** Metadata for infinite query (extends ConvexQueryMeta) */
|
|
628
|
-
type ConvexInfiniteQueryMeta = ConvexQueryMeta & {
|
|
629
|
-
/** The query function name (serializable for RSC) */queryName: string; /** Query args without cursor/limit (user's filter args only) */
|
|
630
|
-
args: Record<string, unknown>; /** Items per page (optional - server uses .paginated() default) */
|
|
631
|
-
limit?: number;
|
|
632
|
-
};
|
|
633
655
|
/** Return type of infiniteQueryOptions - compatible with TanStack prefetch */
|
|
634
656
|
type ConvexInfiniteQueryOptions<T extends FunctionReference<'query'>> = Pick<UseQueryOptions<FunctionReturnType<T>, Error, FunctionReturnType<T>, ConvexQueryKey<T>>, 'queryKey' | 'staleTime' | 'enabled'> & {
|
|
635
657
|
meta: ConvexInfiniteQueryMeta;
|
|
@@ -656,8 +678,6 @@ type DecorateInfiniteQuery<T extends FunctionReference<'query'>> = {
|
|
|
656
678
|
infiniteQueryKey: (args?: DeepPartial<InfiniteQueryInput<FunctionArgs<T>>>) => ConvexQueryKey<T>; /** Function metadata from server (auth, limit, rateLimit, role, type) */
|
|
657
679
|
meta: PaginatedFnMeta;
|
|
658
680
|
};
|
|
659
|
-
/** Mutation variables type - undefined when no args required (allows mutateAsync() without args) */
|
|
660
|
-
type MutationVariables<T extends FunctionReference<'mutation' | 'action'>> = keyof FunctionArgs<T> extends never ? void : EmptyObject extends FunctionArgs<T> ? FunctionArgs<T> | undefined : FunctionArgs<T>;
|
|
661
681
|
/**
|
|
662
682
|
* Decorated mutation procedure with mutationOptions and mutationKey methods.
|
|
663
683
|
*/
|
|
@@ -689,54 +709,16 @@ type VanillaQuery<T extends FunctionReference<'query'>> = {
|
|
|
689
709
|
query: keyof FunctionArgs<T> extends never ? (args?: EmptyObject) => Promise<FunctionReturnType<T>> : EmptyObject extends FunctionArgs<T> ? (args?: FunctionArgs<T>) => Promise<FunctionReturnType<T>> : (args: FunctionArgs<T>) => Promise<FunctionReturnType<T>>;
|
|
690
710
|
watchQuery: keyof FunctionArgs<T> extends never ? (args?: EmptyObject, opts?: WatchQueryOptions) => Watch<FunctionReturnType<T>> : EmptyObject extends FunctionArgs<T> ? (args?: FunctionArgs<T>, opts?: WatchQueryOptions) => Watch<FunctionReturnType<T>> : (args: FunctionArgs<T>, opts?: WatchQueryOptions) => Watch<FunctionReturnType<T>>;
|
|
691
711
|
};
|
|
692
|
-
/** Vanilla mutation - direct .mutate() call without React Query */
|
|
693
|
-
type VanillaMutation<T extends FunctionReference<'mutation'>> = {
|
|
694
|
-
mutate: keyof FunctionArgs<T> extends never ? (args?: EmptyObject) => Promise<FunctionReturnType<T>> : EmptyObject extends FunctionArgs<T> ? (args?: FunctionArgs<T>) => Promise<FunctionReturnType<T>> : (args: FunctionArgs<T>) => Promise<FunctionReturnType<T>>;
|
|
695
|
-
};
|
|
696
|
-
/** Vanilla action - both .query() and .mutate() for direct calls */
|
|
697
|
-
type VanillaAction<T extends FunctionReference<'action'>> = {
|
|
698
|
-
query: keyof FunctionArgs<T> extends never ? (args?: EmptyObject) => Promise<FunctionReturnType<T>> : EmptyObject extends FunctionArgs<T> ? (args?: FunctionArgs<T>) => Promise<FunctionReturnType<T>> : (args: FunctionArgs<T>) => Promise<FunctionReturnType<T>>;
|
|
699
|
-
mutate: keyof FunctionArgs<T> extends never ? (args?: EmptyObject) => Promise<FunctionReturnType<T>> : EmptyObject extends FunctionArgs<T> ? (args?: FunctionArgs<T>) => Promise<FunctionReturnType<T>> : (args: FunctionArgs<T>) => Promise<FunctionReturnType<T>>;
|
|
700
|
-
};
|
|
701
712
|
/**
|
|
702
713
|
* Recursively creates vanilla client type for direct procedural calls.
|
|
703
|
-
* Similar to CRPCClient but for imperative usage outside React Query.
|
|
704
|
-
*
|
|
705
|
-
* @example
|
|
706
|
-
* ```ts
|
|
707
|
-
* const client = useCRPCClient();
|
|
708
|
-
* await client.user.get.query({ id });
|
|
709
|
-
* await client.user.update.mutate({ id, name: 'test' });
|
|
710
|
-
* ```
|
|
711
714
|
*/
|
|
712
715
|
type VanillaCRPCClient<TApi> = { [K in keyof TApi as K extends string ? K extends `_${string}` ? never : K : K]: TApi[K] extends FunctionReference<'query'> ? VanillaQuery<TApi[K]> : TApi[K] extends FunctionReference<'mutation'> ? VanillaMutation<TApi[K]> : TApi[K] extends FunctionReference<'action'> ? VanillaAction<TApi[K]> : TApi[K] extends Record<string, unknown> ? VanillaCRPCClient<TApi[K]> : never };
|
|
713
716
|
/**
|
|
714
717
|
* Recursively decorates all procedures in a Convex API object.
|
|
715
|
-
*
|
|
716
|
-
* - Queries get `queryOptions(args, opts?)`
|
|
717
|
-
* - Paginated queries also get `infiniteQueryOptions(args, opts)`
|
|
718
|
-
* - Mutations get `mutationOptions(opts?)`
|
|
719
|
-
* - Actions get `mutationOptions(opts?)`
|
|
720
|
-
* - Nested objects are recursively decorated
|
|
721
|
-
*
|
|
722
|
-
* @example
|
|
723
|
-
* ```ts
|
|
724
|
-
* type Client = CRPCClient<typeof api>;
|
|
725
|
-
* // Client.user.get.queryOptions({ id }) -> QueryOptions
|
|
726
|
-
* // Client.posts.list.infiniteQueryOptions({ userId }, { initialNumItems: 20 }) -> InfiniteQueryOptions
|
|
727
|
-
* // Client.user.update.mutationOptions() -> MutationOptions
|
|
728
|
-
* ```
|
|
729
718
|
*/
|
|
730
|
-
/** Check if a type has cursor key (pagination detection) */
|
|
731
|
-
type IsPaginated<T> = 'cursor' extends keyof T ? true : false;
|
|
732
719
|
type CRPCClient<TApi> = { [K in keyof TApi as K extends string ? K extends `_${string}` ? never : K : K]: TApi[K] extends FunctionReference<'query'> ? IsPaginated<FunctionArgs<TApi[K]>> extends true ? DecorateQuery<TApi[K]> & DecorateInfiniteQuery<TApi[K]> : DecorateQuery<TApi[K]> : TApi[K] extends FunctionReference<'mutation'> ? DecorateMutation<TApi[K]> : TApi[K] extends FunctionReference<'action'> ? DecorateAction<TApi[K]> : TApi[K] extends Record<string, unknown> ? CRPCClient<TApi[K]> : never };
|
|
733
720
|
//#endregion
|
|
734
|
-
//#region src/
|
|
735
|
-
type HttpRouteInfo = {
|
|
736
|
-
path: string;
|
|
737
|
-
method: string;
|
|
738
|
-
};
|
|
739
|
-
type HttpRouteMap = Record<string, HttpRouteInfo>;
|
|
721
|
+
//#region src/crpc/http-client.d.ts
|
|
740
722
|
/** Form value types (matches Hono's FormValue) */
|
|
741
723
|
type HttpFormValue = string | Blob;
|
|
742
724
|
/**
|
|
@@ -770,6 +752,13 @@ type HttpClientOptions = {
|
|
|
770
752
|
init?: RequestInit; /** Additional headers (or async function returning headers) */
|
|
771
753
|
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
772
754
|
};
|
|
755
|
+
//#endregion
|
|
756
|
+
//#region src/react/http-proxy.d.ts
|
|
757
|
+
type HttpRouteInfo = {
|
|
758
|
+
path: string;
|
|
759
|
+
method: string;
|
|
760
|
+
};
|
|
761
|
+
type HttpRouteMap = Record<string, HttpRouteInfo>;
|
|
773
762
|
/** Infer schema type or return empty object if UnsetMarker */
|
|
774
763
|
type InferSchemaOrEmpty<T> = T extends UnsetMarker ? object : T extends z.ZodTypeAny ? z.infer<T> : object;
|
|
775
764
|
/** Infer merged input from HttpProcedure (flat - used internally) */
|
|
@@ -1260,4 +1249,4 @@ declare function useUploadMutationOptions<TGenerateUrlMutation extends FunctionR
|
|
|
1260
1249
|
*/
|
|
1261
1250
|
declare function createVanillaCRPCProxy<TApi extends Record<string, unknown>>(api: TApi, meta: CallerMeta, convexClient: ConvexReactClient$1, transformer?: DataTransformerOptions): VanillaCRPCClient<TApi>;
|
|
1262
1251
|
//#endregion
|
|
1263
|
-
export { AuthMutationError, AuthProvider, AuthStore, AuthStoreState, Authenticated, CRPCHttpOptions, ConvexAuthBridge, ConvexProvider, ConvexProviderWithAuth, ConvexQueryClient, ConvexQueryClientOptions, ConvexQueryClientSingletonOptions, ConvexReactClient, CreateCRPCContextOptions, FetchAccessTokenContext, FetchAccessTokenFn, HttpCRPCClient, HttpCRPCClientFromRouter, HttpClientOptions, HttpFormValue, HttpInputArgs, HttpMutationKey, HttpProxyOptions, HttpQueryKey, HttpRouteInfo, HttpRouteMap, MaybeAuthenticated, MaybeUnauthenticated, PaginationState, PaginationStatus, Unauthenticated, UseInfiniteQueryResult, VanillaHttpCRPCClient, VanillaHttpCRPCClientFromRouter, createAuthMutations, createCRPCContext, createCRPCOptionsProxy, createHttpProxy, createVanillaCRPCProxy, decodeJwtExp, getConvexQueryClientSingleton, getQueryClientSingleton, isAuthMutationError, useAuth, useAuthGuard, useAuthState, useAuthStore, useAuthValue, useConvex, useConvexActionOptions, useConvexActionQueryOptions, useSafeConvexAuth as useConvexAuth, useSafeConvexAuth, useConvexAuthBridge, useConvexInfiniteQueryOptions, useConvexMutationOptions, useConvexQueryClient, useConvexQueryOptions, useFetchAccessToken, useFnMeta, useInfiniteQuery, useIsAuth, useMaybeAuth, useMeta, useUploadMutationOptions };
|
|
1252
|
+
export { AuthMutationError, AuthProvider, AuthStore, AuthStoreState, Authenticated, CRPCHttpOptions, ConvexAuthBridge, ConvexProvider, ConvexProviderWithAuth, ConvexQueryClient, ConvexQueryClientOptions, ConvexQueryClientSingletonOptions, ConvexReactClient, CreateCRPCContextOptions, FetchAccessTokenContext, FetchAccessTokenFn, HttpCRPCClient, HttpCRPCClientFromRouter, type HttpClientOptions, type HttpFormValue, type HttpInputArgs, HttpMutationKey, HttpProxyOptions, HttpQueryKey, HttpRouteInfo, HttpRouteMap, MaybeAuthenticated, MaybeUnauthenticated, PaginationState, PaginationStatus, Unauthenticated, UseInfiniteQueryResult, VanillaHttpCRPCClient, VanillaHttpCRPCClientFromRouter, createAuthMutations, createCRPCContext, createCRPCOptionsProxy, createHttpProxy, createVanillaCRPCProxy, decodeJwtExp, getConvexQueryClientSingleton, getQueryClientSingleton, isAuthMutationError, useAuth, useAuthGuard, useAuthState, useAuthStore, useAuthValue, useConvex, useConvexActionOptions, useConvexActionQueryOptions, useSafeConvexAuth as useConvexAuth, useSafeConvexAuth, useConvexAuthBridge, useConvexInfiniteQueryOptions, useConvexMutationOptions, useConvexQueryClient, useConvexQueryOptions, useFetchAccessToken, useFnMeta, useInfiniteQuery, useIsAuth, useMaybeAuth, useMeta, useUploadMutationOptions };
|